When using statement based replication in a master-master configuration

there exists a race condition that can break replication when dropping a user.
Ideally one would use the "sql_log_bin: no" option to avoid this but
that is not possible on Google CloudSQL instances. Adding IF EXISTS
clause to the DROP USER statement makes it replication safe without
the need to skip logging.
This commit is contained in:
MattMontgomeryKochava 2022-02-11 17:53:32 -06:00
commit 175ad8899c

View file

@ -368,7 +368,7 @@ def user_delete(cursor, user, host, host_all, check_mode):
hostnames = [host]
for hostname in hostnames:
cursor.execute("DROP USER %s@%s", (user, hostname))
cursor.execute("DROP USER IF EXIST %s@%s", (user, hostname))
return True