Repository navigation
test(platform): keep the RAG sweep's clock off the watchdog lanes - #4145
Merged
Merged
Conversation
The lock lane's tick deferred the locked row as designed. The row was then failed by a second sweep: the harness boots pg-boss with every schedule, and `watchdog.rag_indexing` fires on 2-59/5. The CI failure is in the 04:42 slot. The candidate read is global, and the lane's rows lead every batch, so that tick queued its write behind the held row within its own two-second lock timeout. It failed the row as soon as the lane let go, before the lane read it back. Its own `rag reconcile: adopted 0, failed 2` line follows the FAIL line in the job log. The harness now takes that clock off at boot beside `automation.trigger_scan`, and cancels a tick already queued. The RAG watchdog lane reads that no schedule or tick of the sweep is left. The lock check also reads, before letting go, that nothing still waits on the row once its tick is back. That way a write left behind the lock fails every run, not only when it wins the race against the read-back. Closes #4113
Contributor
Author
|
Independent review of PR #4145 at
Root cause: confirmed from source.
Runtime (mine; PG 16.14 + pgvector, no pg_search)
The one failure in every run is BM25. The lane changes only add checks: a new record, and Your point 4: I choose a follow-up, and don't extend the list here.
INFO, not from this PR:
Whole-PR CI at the exact head (merge ref
Merge: squash with |
This was referenced Oct 3, 2026
tale-code-bot
added a commit
that referenced
this pull request
Oct 30, 2026
The harness unscheduled two recurring jobs at boot, automation.trigger_scan and watchdog.rag_indexing (#4145); every other schedule kept ticking beside lanes that assert exact state: automation.liveness every minute beside the lane that seeds an overdue run and sweeps it, watchdog.transcriptions beside its exact-count lane. createBoss and startBoss take `schedule`, on unless a caller turns it off (spelled out: pg-boss reads a `schedule` key it is handed as undefined as off), and the harness starts pg-boss with it off. pg-boss then starts no clock at all: no cron pass, no __pgboss__send-it forward, so no tick can be queued before a worker starts. schedule() and getSchedules() stay plain SQL: every declared schedule is registered and read back at boot. The per-name list goes. After the lanes, jobs/cron-clock.integration.ts fails the run if a cron pass ran (pgboss.version.cron_on moved) or a tick was forwarded since boot. The RAG lanes' first check now reads only that no sweep job waits or runs. No lane waits for a tick: each drives its recurring job's work itself. Refs #4158
tale-review-bot
pushed a commit
that referenced
this pull request
Oct 30, 2026
The RAG indexing watchdog read its stuck rows, then settled each one by id alone. A Retry that queued a row again between that read and the write was overwritten with the sweep's verdict, mostly failed, until its job rewrote the row. Each of the sweep's six settle writes now also matches the status and the queue stamp (rag_queued_at_ms) it read, with IS NOT DISTINCT FROM for a run never stamped. A row queued again in the meantime keeps its new state, and the sweep counts only the writes that landed. Matching the status alone would still undo a Retry of a stale queued row, which stays queued; every re-queue stamps rag_queued_at_ms afresh, and no job write touches it. FMETA-R6 states the rule. Unit tests hold each write's guard and the race, and a real-Postgres lane holds a sweep between its read and its writes, queues four of its rows again, and reads them back queued under the Retry's stamp, while a row nobody queued again still settles. The Backend integration harness ran pg-boss with its cron clock on and unscheduled only automation.trigger_scan and watchdog.rag_indexing (#4145). Every other recurring job still ticked beside the lanes that drive its work and assert exact state: automation.liveness beside the overdue-run sweep, watchdog.transcriptions beside its exact count. createBoss and startBoss now take schedule, on unless a caller turns it off (main.ts is unchanged), and the harness boots with it off. Every schedule is still registered and checked against SCHEDULES, none ticks, and the per-name list goes. After the lanes, a guard fails the run if pg-boss ran a cron pass or forwarded a tick since boot. Closes #4158 Task: TALE-66
tale-code-bot
added a commit
that referenced
this pull request
Oct 31, 2026
The RAG indexing watchdog read its stuck rows, then settled each one by id alone. A Retry that queued a row again between that read and the write was overwritten with the sweep's verdict, mostly failed, until its job rewrote the row. Each of the sweep's six settle writes now also matches the status and the queue stamp (rag_queued_at_ms) it read, with IS NOT DISTINCT FROM for a run never stamped. A row queued again in the meantime keeps its new state, and the sweep counts only the writes that landed. Matching the status alone would still undo a Retry of a stale queued row, which stays queued; every re-queue stamps rag_queued_at_ms afresh, and no job write touches it. FMETA-R6 states the rule. Unit tests hold each write's guard and the race, and a real-Postgres lane holds a sweep between its read and its writes, queues four of its rows again, and reads them back queued under the Retry's stamp, while a row nobody queued again still settles. The Backend integration harness ran pg-boss with its cron clock on and unscheduled only automation.trigger_scan and watchdog.rag_indexing (#4145). Every other recurring job still ticked beside the lanes that drive its work and assert exact state: automation.liveness beside the overdue-run sweep, watchdog.transcriptions beside its exact count. createBoss and startBoss now take schedule, on unless a caller turns it off (main.ts is unchanged), and the harness boots with it off. Every schedule is still registered and checked against SCHEDULES, none ticks, and the per-name list goes. After the lanes, a guard fails the run if pg-boss ran a cron pass or forwarded a tick since boot. Closes #4158 Task: TALE-66
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.
What failed, and why
The RAG watchdog lock lane (
rag watchdog: a row lock held past the settle lock timeout defers that row alone) readlocked=failed (want running)withtick={"adopted":0,"failed":2,"revived":0}(#4113, run 37097165795, job 111129366409).It is neither of the two readings in the issue:
rag settle failed for file 8189aabd… in org itest-rag-lock-7effa7e9; deferring it: canceling statement due to lock timeout). The tick'sfailed: 2isfirst+after.registerSchedules) and switches off onlyautomation.trigger_scan.watchdog.rag_indexingfires on2-59/5, and its handler is in the task list the harness's worker runs.[watchdog] rag reconcile: adopted 0, failed 2, revived 0line follows the FAIL line. No lane prints it.Deterministic reproduction (local only, not committed)
Real Postgres 16 + pgvector,
ITEST_LANES=checkRagWatchdogBatch, with barriers instead of sleeps. The patch is attached to TALE-494.pg_blocking_pids).watchdog.rag_indexingjob per schedule registered for that queue.main5ee0436 + repro…after 2019 ms…, first=failed locked=failed (want running) after=failed, tick={"adopted":0,"failed":2,"revived":0}) and the scheduled tick's ownrag reconcile: adopted 0, failed 2line. While the lock is held, the locked row still readsrunning, and the only backend still waiting on it is the scheduled tick's.schedules=1 (want 0)andstill waiting on the lock=1 (want 0).The change
integration-check.ts: the harness now switches off thewatchdog.rag_indexingclock at boot, besideautomation.trigger_scan, and cancels any tick already queued. The two are now one list.watchdogs.integration.ts: the lane's ordering is explicit.watchdog.rag_indexingschedule and no queued or running tick of it are left. A clock that comes back fails by name, not as a row another sweep settled. This is the regression: it fails onmain(schedules=1) and passes here.Verified
On this head, the lane and its neighbours (
checkRecoverySweeps,checkRagStatusHintScope,checkRagWatchdogBatch,checkPolicySweeps) ran 10× locally: 10/10 green, 42/43 checks each. The one failure isknowledge BM25 indexes verified at boot, which fails on any host withoutpg_search; CI's tale-db has it.tsc --noEmitscoped to the two files and everything they import: 0 errors.oxlint --type-aware: 0 diagnostics.oxfmt: clean.vitest:integration-scope.guardandintegration-skips.guardpass, 9/9.CI at this head (
7c7de6c2c): 50 pass, 12 skipped by design, 0 fail. Backend integration passed 1504/1504 checks across 222/222 lanes (job 111226456099). The new check readsschedules=0 (want 0), queued or running ticks=0 (want 0). The lock lane readsstill waiting on the lock=0 (want 0), locked=running.Not in this PR
Other lanes are exposed to their own crons in the same way:
watchdog.transcriptions,watchdog.erasures,governance.revoke_idle_sessions,watchdog.conversation_sends,watchdog.deferred_sends,watchdog.object_storage,watchdog.task_agents,tasks.repeat_on_due,websites.scan_due, and others. Each calls the sweep directly and asserts what its own call did. None has a known sighting, so they stay out of this fix. The survey is on TALE-494, and each one is a one-line addition to the new list if wanted.Closes #4113