Repository navigation
fix(tracking): stop making a watched run sit through the ghost thresholds - #761
Merged
Merged
Conversation
…olds A brand's first analysis is started from the UI and its progress bar stays on screen for as long as the drain loop polls. One measured run delivered all 292 of its results in four and a half minutes, then held the bar two tasks short of the total for another forty — waiting on two google-aio tasks that were never going to call back, which is what that scraper does whenever the query has no AI Overview. Across ten days, runs averaged 19 minutes waiting on ghosts against 14 minutes actually receiving results, and 116 of 184 spent more than 15 minutes waiting on nothing. Give a watched run a short tail: once the pending set has shrunk to a negligible remainder and has not moved for about two minutes, stop waiting. Cron runs have no audience and keep the patient thresholds, so a quiet gap mid-burst still cannot cost them results. Leaving early costs the run nothing but an undercounted result_count. /cloro/callback matches a late delivery by task id and inserts the result whether or not the loop is still watching for it. The remainder has a floor of three rather than being a pure percentage: a single-prompt refresh submits about seven tasks, and five per cent of that rounds to one, so a lone ghost would still hold the run open. Track whether the pending set moved above the first-result guard rather than below it. That guard can hold a run indefinitely when the delivery probe never succeeds — the measured run sat there past both the stall cap and the ghost age, exiting on neither because execution never reached them, leaving the 90-minute first-result budget as its only way out. The tail must not depend on that probe: a pending set that has shrunk to a handful is evidence enough that nothing is left worth waiting for, whether those tasks resolved as results, failures or empty responses. Why the probe fails is unresolved and still affects cron runs. Also say what is happening while the tail drains. "2 task(s) still processing" on a bar that has not moved in minutes reads as a hang.
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.
Summary
A brand's first analysis is started from the UI, and its progress bar stays on screen for as long as the drain loop polls. A run measured in production delivered all 292 of its results in four and a half minutes, then held the bar at 292/294 for another forty — waiting on two
google-aiotasks that were never going to call back, which is what that scraper does whenever the query has no AI Overview.This is the normal case, not an outlier. Over ten days:
Every task pending in the database right now is
google-aio.Give a watched run a short tail. Once the pending set has shrunk to a negligible remainder and has not moved for about two minutes, stop waiting. Cron runs have no audience and keep the patient thresholds, so a quiet gap mid-burst still cannot cost them results — the split is
source, whichjob-runneralready sets tomanualorcronand which the drain loop simply never read.Leaving early costs the run nothing but an undercounted
result_count./cloro/callbackmatches a late delivery by task id and inserts the result whether or not the loop is still watching for it.MIN_STAMP_RATIOis 0.5, so a run at 99% still stamps and the dashboard still anchors.The remainder has a floor of three rather than being a pure percentage: a single-prompt refresh submits about seven tasks, and 5% of that rounds to one, so a lone ghost would still hold the run open.
A second problem found while verifying this
The measured run did not exit at the 25-minute stall cap or the 30-minute ghost age. It was still polling at 44 minutes with its pending set untouched since minute five.
Both exits sit below this guard:
When the "delivery started" probe never succeeds, execution never reaches either branch, and the 90-minute first-result budget becomes the only way out.
So this PR tracks whether the pending set moved above that guard, and the tail rule reads that counter instead of the probe. A pending set that has shrunk to a handful is evidence enough that nothing is left worth waiting for, whether those tasks resolved as results, failures or empty responses.
stalledPollskeeps its original semantics exactly, so cron behaviour is unchanged.Why the probe fails is unresolved. It is left alone here rather than guessed at. Cron runs still depend on it and can still wait the full 90 minutes; that wants its own investigation.
Related issue
None — reported directly.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Requires a server deploy.
exitReason: 'tail'andpendingAtExit, at info level —'tail'is an ordinary ending, not a warning.Five tests cover the new helpers, including the measured case (2 of 294 outstanding, two minutes of quiet), the floor that keeps a seven-task run from being held open by one ghost, and the refusal to give up while a meaningful share of the run is still outstanding.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromserver/)yarn format:checkpasses (run fromserver/)yarn testpasses (run fromserver/) — 362 tests