Repository navigation
fix: a backfilled window always attaches with writers held at the parent - #89
Merged
Merged
Conversation
The attach that ends a window partition_data filled tried a plain ATTACH first and fell back to reconcile_and_attach only on a DEFAULT conflict. With nothing left in DEFAULT for the window, the plain attach went through, and an insert into the window that got past the parent while it was in flight chose DEFAULT from the old tree, queued on DEFAULT's lock and was rejected by the narrowed constraint. The current month under a live writer hits that. A filled window now skips the plain attempt and attaches through reconcile_and_attach, which holds writers at the parent and takes the rows that arrived after the last batch, as the docs already describe.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Second thing the Outpost measurement found, after #87. During
backfill, with a writer inserting 20 events a second into the current month, two inserts failed:_attach_with_reconciletries a plainATTACHfirst and moves toreconcile_and_attachonly on a DEFAULT conflict. After a fill, DEFAULT usually holds nothing for the window, so the plain attach goes through. It takesSHARE UPDATE EXCLUSIVEon the parent, which writers pass. An insert for the window that arrives during the attach routes to DEFAULT from the tree as it was, queues on DEFAULT'sACCESS EXCLUSIVE, and once the attach commits it is rejected by DEFAULT's narrowed constraint._lock_for_attachdescribes exactly this race, and the backfill docs already say this attach holds writers at the parent; the code only did when rows had arrived.A window filled from DEFAULT now skips the plain attempt and attaches through
reconcile_and_attach:EXCLUSIVEon the parent, so the insert waits there and lands in the new partition, and whatever arrived after the last batch goes in under the same lock. Attaches that follow no fill are unchanged: create-ahead windows are attached before anything writes into them.The test holds the attach's transaction open after its
ATTACH, sends one insert for the window, waits until it is queued, and lets the attach commit. Before the fix the insert fails with the check violation; after it, it is in the partition.