Commit 5ee0b0a3 by Julien Muchembled

admin: fix possible crash when monitoring a backup cluster that has just switch to BACKINGUP state

This fixes:

  Traceback (most recent call last):
    File "neo/admin/", line 200, in answerLastTransaction
    File "neo/admin/", line 380, in maybeNotify
    File "neo/admin/", line 302, in _notify
      body += '', name, '    ' + backup.formatSummary(upstream)[1]
    File "neo/admin/", line 74, in formatSummary
      tid = self.backup_tid if backup else self.ltid
  AttributeError: 'Backup' object has no attribute 'backup_tid'
parent 7e8ca9ec
......@@ -69,11 +69,21 @@ class Monitor(object):
) if summary else str(self.cluster_state)
if self.down:
summary += '; DOWN=%s' % self.down
if self.operational:
backup = self.cluster_state == ClusterStates.BACKINGUP
tid = self.backup_tid if backup else self.ltid
while self.operational: # not a loop
if self.cluster_state == ClusterStates.BACKINGUP:
tid = self.backup_tid
except AttributeError:
# Possible race when a backup cluster has just switched to
# BACKINGUP state, whereas the next call to app._notify
# will be with ask_ids=False, which means that backup_tid
# will be unknown for this cluster.
tid = self.ltid
upstream = None
x = datetimeFromTID(tid)
if upstream and backup:
if upstream:
lag = (upstream[0] - x).total_seconds()
if lag or tid >= upstream[1]:
lagging = self.max_lag < lag
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment