tgc.church#285: serialize WP-Cron batches per site - #57
Conversation
|
Warning Review limit reached
Next review available in: 44 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughWP-Cron batches now acquire shared per-site leases before spawning. Workers refresh leases during polling and release them after completion, timeout, or spawn failure. Tracking keys now use stable identifiers independent of routing URLs. ChangesWP-Cron lease execution
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/class-worker-process.php`:
- Around line 16-17: Rename the class constants CRON_SITE_LOCK_TTL_SECONDS and
CRON_SITE_LOCK_REFRESH_SECONDS to QW_CRON_SITE_LOCK_TTL_SECONDS and
QW_CRON_SITE_LOCK_REFRESH_SECONDS, and update every reference to use the new
names.
- Around line 736-742: Update the cron lease renewal branch in the worker
process loop around refresh_cron_site_lock() so a false result immediately
terminates and reaps the subprocess, rather than continuing its batch. Preserve
the existing timestamp update on successful renewal, and add a regression test
that simulates renewal failure while the subprocess is active and verifies
termination and reaping.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 715afa90-aca6-44f1-a8ad-bbec69addd7d
📒 Files selected for processing (4)
README.mdsrc/class-job-payload.phpsrc/class-worker-process.phptests/regression.php
Summary
Root cause
Production evidence from
superdav42/tgc.church#285showed that scanner and executor representations of the same recurring event could use different site URLs. Because the URL was part of the tracking key, both representations could bypass the shared job claim. Separate Workerman children could then execute overlapping batches for one site and race while updating WordPress'scronoption.The new per-site lease complements the route-independent event identity: one WP-Cron batch may write a site's cron state at a time, while other sites and Action Scheduler lanes retain their existing concurrency.
Refs superdav42/tgc.church#285.
Verification
composer test:regressioncomposer validate --strictphp -l src/class-job-payload.phpphp -l src/class-worker-process.phpphp -l tests/regression.phpgit diff --check origin/main...HEADPHPStan was also attempted after installing the declared development dependencies. Repository-wide analysis currently reports pre-existing dependency/stub and legacy findings (including Workerman, WP-CLI, and Action Scheduler symbols), so it is not a passing repository gate for this change.
aidevops.sh v3.32.229 plugin for OpenCode v1.18.9 with gpt-5.6-sol
Summary by CodeRabbit
New Features
Documentation