[Bug]: await_lock masks exceptions as FileLockError; minion job_queue requeues forever ("Failed to acquire job_queue lock" log flood)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
What happened?
On 3007.13 two minions got stuck in an infinite requeue loop, logging ~180 lines/s of
[salt.minion :1960][WARNING ] Failed to acquire job_queue lock for jid 2026..., queuing anyway.
for a week, until /var/log/salt/minion reached 9 GB and filled /var. 59 stale jids cycled every 0.3 s. No job_queue.lock file existed, fds were 45/8192, plenty of RAM. The loop started 9 s after a Timeout encountered while sending ... _return request.
Root cause, two defects that combine:
-
salt.utils.files.await_lockhides the real exception. Theyieldis inside the outertry, whoseexcept Exceptionre-raises everything asFileLockError("Error encountered obtaining file lock ..."). Any exception raised by theasync with await_lock(...)body is reported as a lock failure and its traceback is lost. In 3007.13 the body included_invoke_execution()and the proc-file write, so a job-start failure became "Failed to acquire job_queue lock". 3007.14 moved_invoke_executionout of the lock, butawait_lockitself is unchanged in 3008.x, and the minion'sexcept FileLockErrorhandler still logs without the exception. -
The disk job queue has no exit.
_process_process_queue_async_implresubmits everyqueued_*.pfile every 0.3 s (0.2 s in 3008.x) with no retry counter, max age or backoff. A job that fails deterministically at start is requeued forever.
Workaround used: stop minion, move cachedir/job_queue aside, truncate log, start.
Expected
await_lockshould not convert exceptions from thewithbody intoFileLockError(re-raise them unchanged, keep the wrapping for the lock-acquire path only)._handle_decoded_payload'sexcept FileLockErrorshould log the exception (exc_info=True).- Queued jobs need a retry limit and/or max age; after that the job is dropped with an error and a return to the master.
Type of salt install
onedir
Major version
3007 (3007.13); defect 1 and 2 still present in 3008.2 / master
What supported OS are you seeing the problem on?
Ubuntu
salt --versions-report output
Salt Version:
Salt: 3007.13
Python: /opt/saltstack/salt/bin/python3.10 (onedir)
OS: Ubuntu, cPanel hosts
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.utils.files.await_lock and trace its exception handling around the with body, then inspect _handle_decoded_payload and _process_process_queue_async_impl. Confirm that body exceptions remain distinguishable from lock-acquisition failures, that FileLockError logging includes the exception, and that repeatedly failing queued jobs eventually stop requeueing with an error return to the master.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100