diff --git a/changelogs/fragments/479_enable_auto_commit.yml b/changelogs/fragments/479_enable_auto_commit.yml new file mode 100644 index 00000000..5701f305 --- /dev/null +++ b/changelogs/fragments/479_enable_auto_commit.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - mysql_user - enable auto_commit to avoid MySQL metadata table lock (https://github.com/ansible-collections/community.mysql/issues/479). diff --git a/plugins/modules/mysql_user.py b/plugins/modules/mysql_user.py index 8acb8a35..bd488b05 100644 --- a/plugins/modules/mysql_user.py +++ b/plugins/modules/mysql_user.py @@ -433,13 +433,13 @@ def main(): if check_implicit_admin: try: cursor, db_conn = mysql_connect(module, "root", "", config_file, ssl_cert, ssl_key, ssl_ca, db, - connect_timeout=connect_timeout, check_hostname=check_hostname) + connect_timeout=connect_timeout, check_hostname=check_hostname, autocommit=True) except Exception: pass if not cursor: cursor, db_conn = mysql_connect(module, login_user, login_password, config_file, ssl_cert, ssl_key, ssl_ca, db, - connect_timeout=connect_timeout, check_hostname=check_hostname) + connect_timeout=connect_timeout, check_hostname=check_hostname, autocommit=True) except Exception as e: module.fail_json(msg="unable to connect to database, check login_user and login_password are correct or %s has the credentials. " "Exception message: %s" % (config_file, to_native(e)))