Skip to content

db: remove compactionIter's sameStripeNonSkippable#3221

Closed
jbowens wants to merge 2 commits intocockroachdb:masterfrom
jbowens:refac-rangedelcompac
Closed

db: remove compactionIter's sameStripeNonSkippable#3221
jbowens wants to merge 2 commits intocockroachdb:masterfrom
jbowens:refac-rangedelcompac

Conversation

@jbowens
Copy link
Copy Markdown
Contributor

@jbowens jbowens commented Jan 12, 2024

The first commit is from #3219 and should be reviewed there.


This commit removes the compaction iterator's concept of a key that lies within
the same snapshot stripe but is non-skippable. These "non-skippable" keys lead
to bizarre behavior, such as a sequence like:

a.MERGE.5 a.RANGEDEL.4 a.MERGE.4

yielding the separate unmerged a.MERGE.5 and a.MERGE.4 internal keys (Note
a.RANGEDEL.4 does not delete a.MERGE.4 because they share the same sequence
number.)

The sameStripeNonSkippable fell out of the fact that range deletions were
previously interleaved by the input iterator at their start key with their
sequence number. These sameStripeNonSkippable could interrupt any logic
iterating across the keys of a stripe, complicating the compaction iterator
logic. With #3219, range deletions began to be interleaved at their start key
with the maximal sequence number, ensuring they never interrupt the keys of a
snapshot stripe.

In some instances INVALID keys were also returned with sameStripeNonSkippable.
These keys are now treated similarly to other errors encountered during
iteration: i.err is set and newStripeNewKey is returned.

Close #3082.

Remove the keyspan.InternalIteratorShim that was intended to be a temporary
bridge to allow range deletions to be surfaced within the compaction iterator,
replacing it with the keyspan.InterleavingIter. This mirrors the mechanics of
range keys. Follow up work will be able to simplify the compaction iterator
logic now that range deletions are always interleaved at the maximal sequence
number.

Informs cockroachdb#3082.
This commit removes the compaction iterator's concept of a key that lies within
the same snapshot stripe but is non-skippable. These "non-skippable" keys lead
to bizarre behavior, such as a sequence like:

  a.MERGE.5 a.RANGEDEL.4 a.MERGE.4

yielding the separate unmerged a.MERGE.5 and a.MERGE.4 internal keys (Note
a.RANGEDEL.4 does not delete a.MERGE.4 because they share the same sequence
number.)

The sameStripeNonSkippable fell out of the fact that range deletions were
previously interleaved by the input iterator at their start key with their
sequence number. These sameStripeNonSkippable could interrupt any logic
iterating across the keys of a stripe, complicating the compaction iterator
logic. With cockroachdb#3219, range deletions began to be interleaved at their start key
with the maximal sequence number, ensuring they never interrupt the keys of a
snapshot stripe.

In some instances INVALID keys were also returned with sameStripeNonSkippable.
These keys are now treated similarly to other errors encountered during
iteration: i.err is set and newStripeNewKey is returned.

Close cockroachdb#3082.
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@jbowens
Copy link
Copy Markdown
Contributor Author

jbowens commented Jan 16, 2024

Merged into #3219 to produce a more coherent diff.

@jbowens jbowens closed this Jan 16, 2024
@jbowens jbowens deleted the refac-rangedelcompac branch January 16, 2024 19:27
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.

db: refactor/cleanup compaction iterator

2 participants