-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
DropPrefix breaks levels, resulting in hard crashes and data loss #1380
Labels
kind/bug
Something is broken.
priority/P0
Critical issue that requires immediate attention.
status/accepted
We accept to investigate or work on it.
Comments
damz
added a commit
to damz/badger
that referenced
this issue
Jun 22, 2020
Fixes three issues with the current implementation: - It can generate compaction requests that break the invariant that bottom tables need to be consecutive (issue hypermodeinc#1380) - It performs the same level compactions in increasing order of levels (starting from L0) which leads to old versions of keys for the prefix re-surfacing to active transactions - When you have to drop multiple prefixes, the API forces you to drop one prefix at a time and go through the whole expensive table rewriting multiple times.
Merged
damz
added a commit
to damz/badger
that referenced
this issue
Jun 22, 2020
Fixes three issues with the current implementation: - It can generate compaction requests that break the invariant that bottom tables need to be consecutive (issue hypermodeinc#1380) - It performs the same level compactions in increasing order of levels (starting from L0) which leads to old versions of keys for the prefix re-surfacing to active transactions - When you have to drop multiple prefixes, the API forces you to drop one prefix at a time and go through the whole expensive table rewriting multiple times.
The diagram above explains how the current implementation of drop prefix in #1331 can create invalid levels. |
That's exactly that 👍 |
jarifibrahim
pushed a commit
that referenced
this issue
Jun 27, 2020
Fixes three issues with the current implementation: - It can generate compaction requests that break the invariant that bottom tables need to be consecutive (issue #1380). See #1380 (comment) - It performs the same level compactions in increasing order of levels (starting from L0) which leads to old versions of keys for the prefix re-surfacing to active transactions. - When you have to drop multiple prefixes, the API forces you to drop one prefix at a time and go through the whole expensive table rewriting multiple times. Fixes #1381 Co-authored-by: Ibrahim Jarif <[email protected]>
jarifibrahim
pushed a commit
that referenced
this issue
Jul 6, 2020
Fixes three issues with the current implementation: - It can generate compaction requests that break the invariant that bottom tables need to be consecutive (issue #1380). See #1380 (comment) - It performs the same level compactions in increasing order of levels (starting from L0) which leads to old versions of keys for the prefix re-surfacing to active transactions. - When you have to drop multiple prefixes, the API forces you to drop one prefix at a time and go through the whole expensive table rewriting multiple times. Fixes #1381 Co-authored-by: Ibrahim Jarif <[email protected]> (cherry picked from commit e013bfd)
jarifibrahim
pushed a commit
that referenced
this issue
Sep 9, 2020
Fixes three issues with the current implementation: - It can generate compaction requests that break the invariant that bottom tables need to be consecutive (issue #1380). See #1380 (comment) - It performs the same level compactions in increasing order of levels (starting from L0) which leads to old versions of keys for the prefix re-surfacing to active transactions. - When you have to drop multiple prefixes, the API forces you to drop one prefix at a time and go through the whole expensive table rewriting multiple times. Fixes #1381 Co-authored-by: Ibrahim Jarif <[email protected]> (cherry picked from commit e013bfd)
jarifibrahim
pushed a commit
that referenced
this issue
Sep 10, 2020
Fixes three issues with the current implementation: - It can generate compaction requests that break the invariant that bottom tables need to be consecutive (issue #1380). See #1380 (comment) - It performs the same level compactions in increasing order of levels (starting from L0) which leads to old versions of keys for the prefix re-surfacing to active transactions. - When you have to drop multiple prefixes, the API forces you to drop one prefix at a time and go through the whole expensive table rewriting multiple times. Fixes #1381 Co-authored-by: Ibrahim Jarif <[email protected]> (cherry picked from commit e013bfd) Co-authored-by: Damien Tournoud <[email protected]>
jarifibrahim
pushed a commit
that referenced
this issue
Oct 2, 2020
Fixes three issues with the current implementation: - It can generate compaction requests that break the invariant that bottom tables need to be consecutive (issue #1380). See #1380 (comment) - It performs the same level compactions in increasing order of levels (starting from L0) which leads to old versions of keys for the prefix re-surfacing to active transactions. - When you have to drop multiple prefixes, the API forces you to drop one prefix at a time and go through the whole expensive table rewriting multiple times. Fixes #1381 Co-authored-by: Ibrahim Jarif <[email protected]>
manishrjain
pushed a commit
to outcaste-io/outserv
that referenced
this issue
Jul 6, 2022
Fixes three issues with the current implementation: - It can generate compaction requests that break the invariant that bottom tables need to be consecutive (issue #1380). See hypermodeinc/badger#1380 (comment) - It performs the same level compactions in increasing order of levels (starting from L0) which leads to old versions of keys for the prefix re-surfacing to active transactions. - When you have to drop multiple prefixes, the API forces you to drop one prefix at a time and go through the whole expensive table rewriting multiple times. Fixes #1381 Co-authored-by: Ibrahim Jarif <[email protected]>
mYmNeo
pushed a commit
to mYmNeo/badger
that referenced
this issue
Jan 16, 2023
Fixes three issues with the current implementation: - It can generate compaction requests that break the invariant that bottom tables need to be consecutive (issue hypermodeinc#1380). See hypermodeinc#1380 (comment) - It performs the same level compactions in increasing order of levels (starting from L0) which leads to old versions of keys for the prefix re-surfacing to active transactions. - When you have to drop multiple prefixes, the API forces you to drop one prefix at a time and go through the whole expensive table rewriting multiple times. Fixes hypermodeinc#1381 Co-authored-by: Ibrahim Jarif <[email protected]> (cherry picked from commit e013bfd) Co-authored-by: Damien Tournoud <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
kind/bug
Something is broken.
priority/P0
Critical issue that requires immediate attention.
status/accepted
We accept to investigate or work on it.
What version of Go are you using (
go version
)?What operating system are you using?
Linux
What version of Badger are you using?
master
Steps to reproduce the issue
This is actually pretty tricky to reproduce in a synthetic way.
You need a database with a sufficient amount of data so that on one level you have a layout similar to this:
badgerMoveKey
prefix (either actual move keys, or something else), and is not fullIn this case, the
dropPrefix
will generate a same-layer compaction request wherebot
has two non-consecutive tables:https://github.com/dgraph-io/badger/blob/d37ce36911ae349fbedba342f693184aa434cc30/levels.go#L301-L330
If it happens that
compactTables()
generates tables without the same exact boundaries (for example because there were expired keys / deleted keys) then the result will be a layer with overlapping tables.The assumption that
bot
has consecutive tables was broken in #1331This results in data loss, and/or various assertions depending on what compactions are going to happen after that. In our case, we trigger the new assertion added in #1365 and various other assertions.
How to fix?
dropPrefix
should generate a separate compaction request for the move key prefix, instead of trying to generate a single compaction request for everything.The text was updated successfully, but these errors were encountered: