Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix writing aggregation jobs touching GC'ed batches. #2467

Merged
merged 2 commits into from
Jan 10, 2024

Conversation

branlwyd
Copy link
Contributor

This issue should only exist in the time-interval query type, as fixed-size is arranged such that aggregation jobs touching a given batch must be GC'ed before the batch. I include a guard to ensure that the new codepath is only taken in the expected case of an already-GC'ed batch for a time-interval query, as otherwise we might drop batch writes if we fell into it unexpectedly.

This issue should only exist in the time-interval query type, as
fixed-size is arranged such that aggregation jobs touching a given batch
must be GC'ed before the batch. I include a guard to ensure that the new
codepath is only taken in the expected case of an already-GC'ed batch
for a time-interval query, as otherwise we might drop batch writes if we
fell into it unexpectedly.
@branlwyd branlwyd requested a review from a team as a code owner January 10, 2024 04:43
@branlwyd
Copy link
Contributor Author

Closes #2464. (though I still need to evaluate the Helper codepath, which I should split out to a separate issue if there is work needed there)

I'm not totally happy with this fix as it's something of a hack, but I think it's about the best we can do -- the best other solution discussed was to return an is_gc'ed flag from get_batch, but we can't accurately compute that flag for the fixed-size query type.

I verified that the new test reproduces the issue by removing the fix & observing the test fail with an underflow error.

aggregator/src/aggregator/aggregation_job_driver.rs Outdated Show resolved Hide resolved
Comment on lines 1987 to 1989
tx.put_aggregator_task(&leader_task).await?;
tx.put_client_report(vdaf.borrow(), &first_report).await?;
tx.put_client_report(vdaf.borrow(), &second_report).await?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think it's better to call unwrap() here, because then if any of these three puts does fail, it's obvious which one it was. If we propagate the error then it blows up when we unwrap the result from run_unnamed_tx which is less helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I've been making this change as I touch code -- it is indeed much better to fail sooner rather than later in tests. I missed these as I adapted a lot of this code from a previously-existing test.

Comment on lines 361 to 363
if !Q::to_batch_interval(batch_identifier)
.map(|interval| interval.end() < tx.clock().now())
.unwrap_or(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works fine, but we have self.task in scope, so can't we more directly check the query type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we should check both -- I also want to guard against a time-interval task unexpectedly not finding a batch that shouldn't be GC'ed.

@branlwyd branlwyd enabled auto-merge (squash) January 10, 2024 19:19
@branlwyd branlwyd merged commit f257d1e into main Jan 10, 2024
7 checks passed
@branlwyd branlwyd deleted the bran/fix-batch-gc-bug branch January 10, 2024 20:00
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.

3 participants