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/handler.py", line 200, in answerLastTransaction
      app.maybeNotify(name)
    File "neo/admin/app.py", line 380, in maybeNotify
      self._notify(False)
    File "neo/admin/app.py", line 302, in _notify
      body += '', name, '    ' + backup.formatSummary(upstream)[1]
    File "neo/admin/app.py", line 74, in formatSummary
      tid = self.backup_tid if backup else self.ltid
  AttributeError: 'Backup' object has no attribute 'backup_tid'
1 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:
try:
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.
break
else:
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
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!