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

Tsavorite allocator - tighten the packing of pages #657

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

badrishc
Copy link
Contributor

@badrishc badrishc commented Sep 12, 2024

This is a change to the Tsavorite allocator base to make its page-filling algorithm (primarily for TsavoriteLog) deterministic.

We change the allocator to enqueue at tail with the invariant that the first record of page (p+1) is guaranteed to have not fit in the empty space at the end of the previous page (p).

This allows replication to independently replay AOF records and guarantee that they fit on the AOF created on the secondary, exactly in the same way as they do on the primary. I.e., they will be in perfect lockstep.

Previously it was possible that two threads raced to add at the end of a page, the larger allocation won first and closed that page, but the smaller allocation won on the new page and populated the first entry with a record that could have fitted on the previous page. On the replica, this record would end up on the previous page, resulting in offset mismatch.

We already have a workaround in the replica replay logic to correct for this, but this PR makes that workaround unnecessary.

PR also includes an unrelated fix to Upsert logic from Ted: Fix InernalUpsert srcRecordInfo setting when found below ReadOnlyAddress

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.

2 participants