saltstack / saltstack/salt

[BUG] mysqlclient (MySQLdb) import problem 3007.2

Open
#68,041 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
The Salt mysql module fails to load on a minion when using the bundled Python 3.10 environment (/opt/saltstack/salt/bin/python3.10) due to an outdated libstdc++.so.6 in /opt/saltstack/salt/lib. The module’s virtual function returns False with "No python mysql client installed," even though mysqlclient 1.4.6 is installed and MySQLdb is importable in the system Python 3.12.

** Steps to Reproduce **
  1. Install Salt 3007.2 on Ubuntu 24.04.2 LTS with /opt/saltstack as the install path.
  2. Install mysqlclient 1.4.6 in the system Python (/usr/bin/python3).
  3. Verify MySQLdb imports in system Python:
/usr/bin/python3 -c "import MySQLdb"
  1. Attempt to import MySQLdb in Salt's Python:
/opt/saltstack/salt/bin/python3.10 -c "import MySQLdb"

This fails with:

ImportError: /opt/saltstack/salt/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /lib/x86_64-linux-gnu/libmysqlclient.so.21)
  1. Run:
salt-call sys.doc mysql --local

Returns empty output due to __virtual__ returning False.

** Expected Behavior **

The mysql module should load if MySQLdb is installed, using the system’s libstdc++.so.6 (which supports GLIBCXX_3.4.32) instead of Salt’s outdated libstdc++.so.6 (max GLIBCXX_3.4.29).

** Actual Behavior **

The mysql module fails to load because Salt’s Python environment uses an outdated libstdc++.so.6, causing MySQLdb import to fail.

** Environment **
  • Salt Version: 3007.2
  • OS: Ubuntu 24.04.2 LTS
  • Python: System Python 3.1.2, Salt bundled Python 3.10.17
  • MySQL Client: mysqlclient 1.4.6
  • MySQL Server: MySQL 8.0
  • Install Path: /opt/saltstack
** Workaround **
  1. Rename Salt's libstdc++.so.6:
    mv /opt/saltstack/salt/lib/libstdc++.so.6 /opt/saltstack/salt/lib/libstdc++.so.6.bak
    
  2. Clear cache and restart:
    rm -rf /var/cache/salt/minion/*
    systemctl restart salt-minion
    
** Suggested Fix **
  • Update the bundled libstdc++.so.6 in /opt/saltstack/salt/lib to support GLIBCXX_3.4.32
  • Prioritize system libraries over bundled ones
  • Improve __virtual__ error messages to include import failure details.
Additional notes

The system's libstdc++.so.6 supports GLIBCXX_3.4.32. This affects states like mysql_user.present. I had a state file for the workaround, but it failed for various reasons so I removed it and replaced it by modifying my bootstrap script.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the MySQLdb import with /opt/saltstack/salt/bin/python3.10 and compare its library loading with /usr/bin/python3, focusing on /opt/saltstack/salt/lib/libstdc++.so.6. Read the mysql module’s virtual function and verify the result with salt-call sys.doc mysql --local. Done means the mysql module loads without renaming the bundled library and import failures remain informative.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, python
Domain
databases, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.