diff options
| author | Csaba Henk <csaba@gluster.com> | 2011-04-11 04:09:15 +0000 | 
|---|---|---|
| committer | Anand Avati <avati@gluster.com> | 2011-04-11 03:52:25 -0700 | 
| commit | dd3cc7d398c3b4432097b7cc2716e2afec9a8e47 (patch) | |
| tree | 9e42ec5f33deed5ba1785e432a17eaa0e90a81bd | |
| parent | b003ee6e9e8316a59a1de204f727748e442ef0af (diff) | |
syncdaemon: fix setting None as new master
We checked for the event of a new master being adopted by:
- checking for state change in list of masters
- checking if our chosen master is a foreign one
and if these held, then wrote out the actually available master to config
However this was flaky: if
(1) native master changed
(2) there was already a foreign master adopted
(3) actually the master was not available
then we wrote out the None to config.
This could occur if:
- on syncd startup, native master just changes from None to the volume native
  [implies (1)]
- foreign master adopted from earlier run via config [implies (2)]
- actually foreign master was not available [implies (3)]
Signed-off-by: Csaba Henk <csaba@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2670 (strange behaviour with intermediate-master and slave)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2670
| -rw-r--r-- | xlators/features/marker/utils/syncdaemon/master.py | 11 | 
1 files changed, 6 insertions, 5 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/master.py b/xlators/features/marker/utils/syncdaemon/master.py index 87610f3879a..fd5a2dcda3c 100644 --- a/xlators/features/marker/utils/syncdaemon/master.py +++ b/xlators/features/marker/utils/syncdaemon/master.py @@ -142,11 +142,12 @@ class GMaster(object):          # store the value below "boxed" to emulate proper closures          # (variables of the enclosing scope are available inner functions          # provided they are no reassigned; mutation is OK). -        param = FreeObject(relax_mismatch = False, state_change = False) +        param = FreeObject(relax_mismatch = False, state_change = None, index=-1)          def select_vi(vi0, vi): +            param.index += 1              if vi and (not vi0 or vi0['uuid'] == vi['uuid']):                  if not vi0 and not param.relax_mismatch: -                    param.state_change = True +                    param.state_change = param.index                  # valid new value found; for the rest, we are graceful about                  # uuid mismatch                  param.relax_mismatch = True @@ -176,10 +177,10 @@ class GMaster(object):                  self.volinfo = volinfo_sys[self.KFGN]              else:                  self.volinfo = volinfo_sys[self.KNAT] -            if state_change: +            if state_change == self.KFGN or (state_change == self.KNAT and not self.inter_master):                  logging.info('new master is %s', self.uuid) -                if self.inter_master: -                    gconf.configinterface.set('volume_id', self.uuid) +            if state_change == self.KFGN: +               gconf.configinterface.set('volume_id', self.uuid)              if self.volinfo:                  if self.volinfo['retval']:                      raise RuntimeError ("master is corrupt")  | 
