Repository navigation
LVT-382: Batch worker imports to allow database idle windows - #132
Conversation
Snapshot due jobs once, preserve leases and retries, and disconnect after draining. Move API maintenance into the worker and finalize archived imports so scheduled offseason windows can finish. Keep continuous event mode as the default until Railway preview sleep and cold-start gates are verified.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🚅 Deployed to the lovat-pr-132 environment in lovat
1 service not affected by this PR
|
📱 Connect your app to this PR deploymentScan a QR code to use this PR's Server API. Worker changes use the same API; Server URL: |
Lovat AI review failedStatus: failed · Model: The automated review did not complete. The latest commit has not been fully reviewed. This is not a clean review. Error: OpenRouter stopped because the output token limit was reached. Increase maxOutputTokens or reduce the review batch size. Unreviewed commit: Push a new commit or re-run the workflow after fixing the failure. |
jackshim415
left a comment
There was a problem hiding this comment.
Reviewed the batch snapshot/claim boundary, fresh lease timing, token-fenced completion/finalization, retry preservation, heartbeat draining, API import ownership, maintenance retention and both deployment graphs. No blocking code findings in this revision. Local verification: 67 Worker tests (66 suite plus the added maintenance integration), 1,454 Server tests, Server build/typechecks/lint and five IaC tests. The separate Codex code review completed without findings on the identical implementation commit; the latest commit only corrects operational documentation. The OpenRouter review hit its output limit and is being retried. Actual database sleep/billing, cold-query latency and scheduled operating-mode cutovers remain rollout gates, not verified savings.
jackshim415
left a comment
There was a problem hiding this comment.
Final merge review: required Monorepo CI passed, including Server, Worker and cross-app contracts; Railway IaC and CodeQL analysis also passed. The optional OpenRouter reviewer failed twice on its 16,384-token output limit, so it did not provide a completed review. This is an infrastructure limitation, not a passing review. Manual review and the separate Codex code review found no blocking code issues. No merge-rule bypass is needed: the repository requires Monorepo CI, which is green. Rollout sleep/cost/cold-start evidence remains pending as documented.
What changed
Background imports currently poll PostgreSQL all day. Add a finite
WORKER_MODE=batchthat snapshots due work, processes each job at most once with bounded consumers and fresh atomic leases, drains heartbeats, disconnects Prisma and exits. Retries and newly discovered child jobs wait for the next external window. Continuous mode remains the default for minute-level competition refreshes.Move remaining API team/match timers and cleanup ownership to the durable Worker queue. Daily maintenance preserves read-time expiry and thirty-day draft payload retention; successful archived imports and explicit gap jobs finalize instead of recurring forever. Add opt-in Railway Cron rendering and a preview/production/rollback runbook. Related: LVT-335 and LVT-376; broader resource tuning stays with those issues.
Areas affected
Contracts and data
Verification
git diff --checkpassed.Deployment
No migrations. Deploy Worker first and verify maintenance before API cutover; old API replicas retain timers until drained. Existing deployments remain continuous unless the Cron graph is explicitly applied. Daily 18:00 UTC is provisional; pre-event windows run four times/day. Schedule both event-mode cutovers before enabling Cron. Bootstrap catalog child jobs with a second batch.
Actual Railway sleep/billing and cold-start measurements remain pending operational gates. The plugin account exposes only
crux, but the local CLI has Lovat access and Railway automatically provisions this PR's preview. No Cron or PostgreSQL sleep settings were applied. Keep LVT-382 open for the evidence and rollout gates indocs/worker-batch-rollout.md; this PR does not claim measured savings.