Skip to content

Commit

Permalink
Merge pull request Aiven-Open#110 from aiven/kmichel-fix-restore-failure
Browse files Browse the repository at this point in the history
Don't crash if Relay_Log_File cannot be read

Aiven-Open#110
  • Loading branch information
packi committed Dec 12, 2022
2 parents be391fb + 9629527 commit 6e7128d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions myhoard/restore_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,9 @@ def _generate_updated_relay_log_index(self, binlogs, names, cursor):
# Should already be stopped but just to make sure
cursor.execute("STOP SLAVE")
cursor.execute("SHOW SLAVE STATUS")
initial_relay_log_file = cursor.fetchone()["Relay_Log_File"]
replica_status = cursor.fetchone()
# replica_status can be none if RESET REPLICA has been performed or if the replica never was running
initial_relay_log_file = replica_status["Relay_Log_File"] if replica_status is not None else None

# Technically we'd want one fewer relay log file here but the server seems to have some
# caching logic related to the current relay log and we need to make sure currently active
Expand All @@ -1111,7 +1113,9 @@ def _generate_updated_relay_log_index(self, binlogs, names, cursor):
index_file.write(("\n".join(names) + "\n").encode("utf-8"))
self.update_state(last_flushed_index=last_flushed_index, write_relay_log_manually=False)
cursor.execute("SHOW SLAVE STATUS")
final_relay_log_file = cursor.fetchone()["Relay_Log_File"]
replica_status = cursor.fetchone()
# replica_status can be none if RESET REPLICA has been performed or if the replica never was running
final_relay_log_file = replica_status["Relay_Log_File"] if replica_status is not None else None
self.log.info(
"Flushed relay logs %d times, initial file was %r and current is %r",
flush_count,
Expand Down

0 comments on commit 6e7128d

Please sign in to comment.