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

storage: fix CheckSSTConflicts handling of MVCC range keys #94045

Merged

Conversation

erikgrinaker
Copy link
Contributor

CheckSSTConflicts keeps an SST and engine iterator in sync while checking for conflicts. To avoid seek costs, it attempts to step the engine iterator in case the corresponding SST key is nearby. However, this stepping could step right past an MVCC range key overlapping the SST key, which would break conflict checks with MVCC range tombstones.

This patch seeks the engine iterator back to the SST key if we step past it and the range key changed.

Resolves #93968.

Release note (bug fix): When experimental MVCC range tombstones are enabled (they're disabled by default), a bulk ingestion (e.g. an import) could in some situations fail to properly check for conflicts with existing MVCC range tombstones. This could cause the ingestion to write below a recently written MVCC range tombstone, in turn losing the ingested data. This could only happen in rare circumstances where a bulk ingestion was applied concurrently with an import cancellation.

@erikgrinaker erikgrinaker requested review from itsbilal and a team December 21, 2022 11:22
@erikgrinaker erikgrinaker self-assigned this Dec 21, 2022
@erikgrinaker erikgrinaker requested review from a team as code owners December 21, 2022 11:22
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@itsbilal itsbilal left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for fixing this as well!

pkg/kv/kvserver/batcheval/cmd_add_sstable_test.go Outdated Show resolved Hide resolved
`CheckSSTConflicts` keeps an SST and engine iterator in sync while
checking for conflicts. To avoid seek costs, it attempts to step the
engine iterator in case the corresponding SST key is nearby. However,
this stepping could step right past an MVCC range key overlapping the
SST key, which would break conflict checks with MVCC range tombstones.

This patch seeks the engine iterator back to the SST key if we step past
it and the range key changed.

Release note (bug fix): When experimental MVCC range tombstones are
enabled (they're disabled by default), a bulk ingestion (e.g. an import)
could in some situations fail to properly check for conflicts with
existing MVCC range tombstones. This could cause the ingestion to write
below a recently written MVCC range tombstone, in turn losing the
ingested data. This could only happen in rare circumstances where a bulk
ingestion was applied concurrently with an import cancellation.
@erikgrinaker erikgrinaker force-pushed the checksstconflicts-skipped-range-keys branch from 2d2fb18 to 0c024e0 Compare December 21, 2022 17:29
@erikgrinaker
Copy link
Contributor Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Dec 21, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Dec 21, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Dec 21, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Dec 21, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Dec 22, 2022

Build succeeded:

@craig craig bot merged commit a2d9a0e into cockroachdb:master Dec 22, 2022
@erikgrinaker erikgrinaker deleted the checksstconflicts-skipped-range-keys branch December 28, 2022 11:22
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.

batcheval: AddSSTable can write at same timestamp as MVCC range tombstone
3 participants