[BUG] mysqlclient (MySQLdb) import problem 3007.2
Nobody has claimed this yet.
- 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 **
- Install Salt 3007.2 on Ubuntu 24.04.2 LTS with
/opt/saltstackas the install path. - Install
mysqlclient1.4.6 in the system Python (/usr/bin/python3). - Verify
MySQLdbimports in system Python:
/usr/bin/python3 -c "import MySQLdb"
- Attempt to import
MySQLdbin 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)
- 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:
mysqlclient1.4.6 - MySQL Server: MySQL 8.0
- Install Path: /opt/saltstack
** Workaround **
- Rename Salt's
libstdc++.so.6:mv /opt/saltstack/salt/lib/libstdc++.so.6 /opt/saltstack/salt/lib/libstdc++.so.6.bak - Clear cache and restart:
rm -rf /var/cache/salt/minion/* systemctl restart salt-minion
** Suggested Fix **
- Update the bundled
libstdc++.so.6in/opt/saltstack/salt/libto 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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