Fix search of max sequence number

It was observed that sometimes during
galera ckuster restart the node with highest
seqno is determined incorrecly. After investigation
it was found that max function is invoked on the
list of string values which can lead to incorrect results.
This patch performs casting the value to integer before building
list of seqnos hence max function will return correct result

Change-Id: I604ec837f3f2d157c829ab43a44e561879775c77
This commit is contained in:
Oleksii Grudev 2019-10-23 15:39:47 +03:00
parent 1c9cc1cb1d
commit 4d808243f0

View File

@ -619,7 +619,8 @@ def get_nodes_with_highest_seqno():
key = keyitems[0] key = keyitems[0]
node = keyitems[1] node = keyitems[1]
if key == 'seqno': if key == 'seqno':
seqnos[node] = value #Explicit casting to integer to have resulting list of integers for correct comparison
seqnos[node] = int(value)
max_seqno = max(seqnos.values()) max_seqno = max(seqnos.values())
max_seqno_nodes = sorted([k for k, v in list(seqnos.items()) if v == max_seqno]) max_seqno_nodes = sorted([k for k, v in list(seqnos.items()) if v == max_seqno])
return max_seqno_nodes return max_seqno_nodes