Skip to content

fix(server): spawn config/process.php managed workers (restore scan worker)#310

Merged
detain merged 1 commit into
masterfrom
fix/restore-managed-scan-worker
Jun 23, 2026
Merged

fix(server): spawn config/process.php managed workers (restore scan worker)#310
detain merged 1 commit into
masterfrom
fix/restore-managed-scan-worker

Conversation

@detain

@detain detain commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Symptom

Queued library scans/rescans/matching stopped being picked up — they sit in library_scan_jobs as queued forever ("used to go straight from queued to scanning").

Root cause

config/process.php defines the library-scan + plugin-auto-update pollers, and the hand-rolled start.php was 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 standalone scripts/run-library-scan-worker.php by hand — which crash-loops on Swoole io_uring Cannot allocate memory under the default RLIMIT_MEMLOCK (the systemd service sets LimitMEMLOCK=infinity; a CLI/ssh shell does not).

Fix

Restore the config-driven spawn in start.php: each enabled config/process.php entry becomes a count-sized sibling Worker under the same runAll() group, built inside onWorkerStart with the curated coroutine hooks + the service's memlock — mirroring the existing phlix-hub-heartbeat / phlix-relay-tunnel workers. 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 -l clean. Verified on the live box: the phlix-library-scan worker starts and the queued jobs drain (see PR thread).

🤖 Generated with Claude Code

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>
@detain detain merged commit d87b8b1 into master Jun 23, 2026
@detain detain deleted the fix/restore-managed-scan-worker branch June 23, 2026 20:21
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.27%. Comparing base (20c0c44) to head (7d28cf7).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant