[BUG] Mysql returner raises decimal.ConversionSyntax / InvalidOperation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
While using event_return: [mysql], some requests are returning exception decimal.ConversionSyntax.
❗ This is reproducible with Python mysqlclient package, except with pymysql==1.1.0 which does work.
https://github.com/saltstack/salt/blob/v3006.3/salt/returners/mysql.py#L631-L634
https://github.com/saltstack/salt/blob/v3006.3/salt/returners/mysql.py#L376-L377
Setup
Using Docker image https://github.com/saltstack/salt/releases/tag/v3006.3 , customized to install dependencies:
- Alpine
mariadb-devdrivers to build python package mysqlclient==2.2.0
📝 Logs
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/salt/utils/process.py", line 993, in wrapped_run_func
return run_func()
File "/usr/local/lib/python3.10/site-packages/salt/master.py", line 265, in run
salt.daemons.masterapi.clean_old_jobs(self.opts)
File "/usr/local/lib/python3.10/site-packages/salt/daemons/masterapi.py", line 161, in clean_old_jobs
mminion.returners[fstr]()
File "/usr/local/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
ret = self.loader.run(run_func, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/salt/returners/mysql.py", line 634, in clean_old_jobs
cur.execute(sql)
File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 179, in execute
res = self._query(mogrified_query)
File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 332, in _query
self._post_get_result()
File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 366, in _post_get_result
self._rows = self._fetch_row(0)
File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 339, in _fetch_row
return self._result.fetch_row(size, self._fetch_type)
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]
[WARNING ] Returner unavailable: [<class 'decimal.ConversionSyntax'>]
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/salt/client/__init__.py", line 1153, in get_iter_returns
if not self.returns_for_job(jid):
File "/usr/local/lib/python3.10/site-packages/salt/client/__init__.py", line 1115, in returns_for_job
return self.returners["{}.get_load".format(self.opts["master_job_cache"])](jid)
File "/usr/local/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
ret = self.loader.run(run_func, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
return _func_or_method(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/salt/returners/mysql.py", line 377, in get_load
cur.execute(sql, (jid,))
File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 179, in execute
res = self._query(mogrified_query)
File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 332, in _query
self._post_get_result()
File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 366, in _post_get_result
self._rows = self._fetch_row(0)
File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 339, in _fetch_row
return self._result.fetch_row(size, self._fetch_type)
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]
Config
netapi_enable_clients:
- local
- local_async
- runner
- runner_async
- wheel
event_return: [mysql]
master_job_cache: mysql
mysql.host: 'database-host'
mysql.user: 'alcali'
mysql.pass: 'alcali'
mysql.db: 'salt'
mysql.port: 3306
# alterning keep_jobs_seconds does execute a query causing errors.
#keep_jobs_seconds: 0
keep_acl_in_token: True
Additional context
Attempting to use https://alcali.dev/ . In the end i could workaround with pymysql connector.
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 with salt/returners/mysql.py at lines 376-377 and 631-634, then reproduce the returner queries using mysqlclient==2.2.0 and compare with pymysql==1.1.0. Done means the mysql returner no longer raises decimal.InvalidOperation for get_load and clean_old_jobs with the reported setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100