From 175ad8899cededb84290a7a29725e67bf841526a Mon Sep 17 00:00:00 2001 From: MattMontgomeryKochava Date: Fri, 11 Feb 2022 17:53:32 -0600 Subject: [PATCH] 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. --- plugins/module_utils/user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index a523534..24f7658 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -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