Skip to content

pipeline: Keep recheck requests while waiting for their comments. - #4

Open
rosemarie-o wants to merge 1 commit into
fuzzfactor:mainfrom
rosemarie-o:keep-rechecks
Open

rosemarie-o wants to merge 1 commit into
fuzzfactor:mainfrom
rosemarie-o:keep-rechecks

Conversation

@rosemarie-o

Copy link
Copy Markdown

A recheck request is a reply to a patch email. The scan of the dev archive matches the reply to a tracked patch and marks it to have its comments fetched; comment events mark the same. The fetch then reads the reply back from Patchwork, which turns list emails into comments, and parses the request out of it.

The mark was not saved. It was set straight on the patch, without marking its history shard changed, and only changed shards are written; the usual target of a recheck is a finished series, which lives in history. A request not served within the same run of the bot, for example while Patchwork was unavailable, was lost: the next run saw no mark, and the reply is only new in a single scan.

A fetch that returned no comments consumed the mark as well. Patchwork can answer again before it ingests the reply, so the request was dropped with nothing delivered, and nothing would look at the comments of that patch again.

Mark the patch changed when asking for its comments, and note when that was, so that the request survives the run. Keep it until a fetch returns a comment newer than the ones already seen, or for six hours, and record giving up as a decision of the patch. Bump the state schema for the note.

Count only the time Patchwork was available against the six hours, since it ingests nothing while down. Patchwork often fails for a few minutes many times in a row: the bot has seen 34 such periods add up to over seven hours in a single day, which would use up the wait however it was started. The availability record already keeps these periods, so nothing more is stored.

Do not mark the patch changed while it only waits: its history shard holds a whole month, which would then be marshalled and compared with the file on every run. Mark it only when the request is served, when the start of the wait is first noted, or when the wait gives up.

Fixes #3

A recheck request is a reply to a patch email.  The scan of the dev
archive matches the reply to a tracked patch and marks it to have
its comments fetched; comment events mark the same.  The fetch then
reads the reply back from Patchwork, which turns list emails into
comments, and parses the request out of it.

The mark was not saved.  It was set straight on the patch, without
marking its history shard changed, and only changed shards are
written; the usual target of a recheck is a finished series, which
lives in history.  A request not served within the same run of the
bot, for example while Patchwork was unavailable, was lost: the
next run saw no mark, and the reply is only new in a single scan.

A fetch that returned no comments consumed the mark as well.
Patchwork can answer again before it ingests the reply, so the
request was dropped with nothing delivered, and nothing would look
at the comments of that patch again.

Mark the patch changed when asking for its comments, and note when
that was, so that the request survives the run.  Keep it until a
fetch returns a comment newer than the ones already seen, or for
six hours, and record giving up as a decision of the patch.  Bump
the state schema for the note.

Count only the time Patchwork was available against the six hours,
since it ingests nothing while down.  Patchwork often fails for a
few minutes many times in a row: the bot has seen 34 such periods
add up to over seven hours in a single day, which would use up the
wait however it was started.  The availability record already keeps
these periods, so nothing more is stored.

Do not mark the patch changed while it only waits: its history shard
holds a whole month, which would then be marshalled and compared with
the file on every run.  Mark it only when the request is served, when
the start of the wait is first noted, or when the wait gives up.

Fixes fuzzfactor#3

Signed-off-by: Rosemarie O'Riorden <rosemarie@redhat.com>
@igsilya

igsilya commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

From my agent to your's (based on my own investigation and comments):

Thanks for tracking this down. The cause is right: a finished series lives in a history file, which is only written when a change is marked, so the comment scan was lost with the run. The fix and its tests cover what happened in #3. Before merging, please rework it as follows.

Structure

  1. Please split the commit into two:
    • Saving the comment scans of finished series: mark the patch changed whenever its comments are to be scanned and when they were fetched. This alone would have saved the recheck in Some rechecks skipped #3.
    • Waiting for comments that Patchwork stores late: keep the scan when a fetch finds no new comment, with the timeout and the availability counting.
  2. Please route every change to CommentsPending (and CommentsPendingSince) through one helper that also marks the patch changed, for example markComments(pt, pending bool). Today the flag is set in four places, and each has to remember PatchChanged on its own. That's how this bug happened, and a helper prevents it from coming back. Please do the same for the other repeated code in this area.
  3. Please add a test-wide check that the saved state matches the state in memory. In env.reload() in fakes_test.go, after saving, load the state from disk and compare the queue and every history month with the ones in memory. This catches any change to a finished series that isn't marked, in every test, not just the ones written for it. It passes on top of your change.

Behaviour

  1. Please drop the comments-skipped decision and only log giving up. A patch's decision history should only record recheck requests that were actually made.
  2. Please don't fetch on every polling cycle while waiting. Each waiting patch costs a Patchwork request every 3 minutes, for at least 6 hours of Patchwork answering, so 120 or more requests per patch. Every reply that matches by subject but isn't a comment on that patch runs the full wait, for example one to another version or to the cover letter. A minimum interval between fetches would avoid most of that, such as 15 minutes per patch, kept in memory so it doesn't add state commits.

Style

  1. Please keep comments short and on point, and remove the ones that restate the code. Several blocks run to five or more lines where one would do.
  2. Please make the commit messages shorter too: what was wrong, and what the commit changes.
  3. "it ingests nothing while down": the bot only sees the API failing, and Patchwork may still store mail while its API answers errors. Please describe what's known instead: only the time Patchwork answered counts.
  4. The give-up message prints commentWait as "6h0m0s". Please write it as "6 hours".
  5. Line 73 of internal/state/availability_test.go is over 100 columns.

For later, not for this PR

  1. If two replies match the same patch in one scan, the wait ends with the first comment that arrives. A recheck in the second reply is lost if Patchwork stores it later. That's rare and can be handled separately.

@rosemarie-o

Copy link
Copy Markdown
Author

Ok thank you, these seem to be good findings. I started splitting the commit into 2 yesterday, and that's a good point about having one helper to set the flag. I can post a new version of this sometime soon.

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.

Some rechecks skipped

2 participants