[Mariadb] Initialize variable

There are scenarios where the wsrep_rec_pos variable is being returned
without it being first initialized when the .communicate() method
returns a blank. This patchset sets up a default initialization, so
the readiness check does not error out with an exception.

Change-Id: Ifea922f446bf3cbc9220f39a41dffc2763e6a5f3
Signed-off-by: Tin Lam <tin@irrational.io>
This commit is contained in:
Tin Lam 2020-03-26 11:15:17 -05:00
parent af9ac277e8
commit df4cc7827d

View File

@ -549,11 +549,14 @@ def update_grastate_on_restart():
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
out, err = wsrep_recover.communicate() out, err = wsrep_recover.communicate()
wsrep_rec_pos = '-1'
for item in err.split("\n"): for item in err.split("\n"):
logger.info("Recovering wsrep position: {0}".format(item)) logger.info("Recovering wsrep position: {0}".format(item))
if "WSREP: Recovered position:" in item: if "WSREP: Recovered position:" in item:
line = item.strip().split() line = item.strip().split()
wsrep_rec_pos = line[-1].split(':')[-1] wsrep_rec_pos = line[-1].split(':')[-1]
if wsrep_rec_pos == '-1':
logger.info("Setting wsrep position to -1.")
return wsrep_rec_pos return wsrep_rec_pos
set_grastate_val(key='seqno', value=recover_wsrep_position()) set_grastate_val(key='seqno', value=recover_wsrep_position())