fix(server): spawn config/process.php managed workers (restore scan worker)#310
Merged
Conversation
The library-scan (and plugin-auto-update) workers are defined in config/process.php and were originally spawned as sibling Workers by the hand-rolled start.php, but that spawn loop was dropped during the Swoole event-loop refactor — leaving the comment but not the code. As a result the main service never drained library_scan_jobs; scans/rescans/matching only ran if an operator launched scripts/run-library-scan-worker.php by hand, and that standalone path crash-loops on Swoole io_uring ENOMEM under the default RLIMIT_MEMLOCK (the service has LimitMEMLOCK=infinity, the CLI does not). Restore the config-driven spawn: each enabled config/process.php entry becomes a count-sized sibling Worker under runAll(), running with the curated coroutine hooks + the service's memlock — so queued scans go straight to scanning again with no separate process to babysit. Guarded inner+outer so a build failure can't take down HTTP or tight-loop re-fork. Standalone script still works as an alternative (claimNext() is an atomic single-claimer). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #310 +/- ##
============================================
- Coverage 59.27% 59.27% -0.01%
Complexity 12623 12623
============================================
Files 474 474
Lines 41472 41472
============================================
- Hits 24582 24581 -1
- Misses 16890 16891 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
Queued library scans/rescans/matching stopped being picked up — they sit in
library_scan_jobsasqueuedforever ("used to go straight from queued to scanning").Root cause
config/process.phpdefines thelibrary-scan+plugin-auto-updatepollers, and the hand-rolledstart.phpwas supposed to spawn them as sibling Workers (the comment block still says so) — but the actual spawn loop was dropped during the Swoole event-loop refactor. So the main service never drained the queue. It only worked while someone ran the standalonescripts/run-library-scan-worker.phpby hand — which crash-loops on Swoole io_uringCannot allocate memoryunder the defaultRLIMIT_MEMLOCK(the systemd service setsLimitMEMLOCK=infinity; a CLI/ssh shell does not).Fix
Restore the config-driven spawn in
start.php: each enabledconfig/process.phpentry becomes acount-sized siblingWorkerunder the samerunAll()group, built insideonWorkerStartwith the curated coroutine hooks + the service's memlock — mirroring the existingphlix-hub-heartbeat/phlix-relay-tunnelworkers. Queued scans go straight to scanning again, supervised by the main service (survives reboots/deploys), no separate process to babysit. Guarded inner+outer so a build failure can't crash HTTP or tight-loop re-fork. The standalone script still works (claimNext() is an atomic single-claimer).php -lclean. Verified on the live box: thephlix-library-scanworker starts and the queued jobs drain (see PR thread).🤖 Generated with Claude Code