Skip to content

Commit

Permalink
mysql_user: enabled autocommit to support MySQL 8 (ansible-collection…
Browse files Browse the repository at this point in the history
…s#483)

* mysql_user: enabled autocommit to support MySQL 8

* Add changelog fragment

* Link to issue instead of pull request in changelog fragment

Co-authored-by: Andrew Klychkov <[email protected]>

Co-authored-by: Andrew Klychkov <[email protected]>
  • Loading branch information
GhostLyrics and Andersson007 authored Jan 17, 2023
1 parent 4ad7177 commit c242584
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/479_enable_auto_commit.yml
Original file line number Diff line number Diff line change
@@ -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).
4 changes: 2 additions & 2 deletions plugins/modules/mysql_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit c242584

Please sign in to comment.