-
Notifications
You must be signed in to change notification settings - Fork 444
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
db: fix WAL replay in read-only mode #524
Conversation
The new
The problem is that we're creating the memtable in As I looked more, I think there is a more serious problem that could affect compatibility with RocksDB. I suspect what we have to do is to pass in the last unflushed seqnum to @itsbilal and @sumeerbhola can you scrutinize this logic and see if I'm missing anything. |
This was remarkably easy to do. |
Oops, accidentally clicked the close button some how.
I spoke too soon. This actually has a lot of negative effects. Surprisingly many. Which makes me think RocksDB is not doing this. I'm going to dive into the RocksDB code and figure out exactly how and when it sets |
f2d3796
to
3091fac
Compare
Ok, this is all fixed up and ready for a look. I left a comment on where we assign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 5 files reviewed, 1 unresolved discussion (waiting on @itsbilal and @sumeerbhola)
db.go, line 1366 at r1 (raw file):
if b != nil { logSeqNum = b.SeqNum() if b.flushable != nil {
This appears to have been a bug. I'm still trying to write a test which triggers it.
3091fac
to
80b5fb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 6 files reviewed, all discussions resolved (waiting on @itsbilal and @sumeerbhola)
db.go, line 1366 at r1 (raw file):
Previously, petermattis (Peter Mattis) wrote…
This appears to have been a bug. I'm still trying to write a test which triggers it.
Ok, test added. I believe these was innocuous. The effect was that memTable.logSeqNum
would be smaller than the minimum sequence number added to the memTable
. This would cause the memTable
to prevent L0->L0 compactions in very rare circumstances, and cause the memTable
to be accessed on reads unnecessarily in very rare circumstances.
80b5fb8
to
ed80277
Compare
The addition of `memTable.logSeqNum` broke WAL replay in read-only mode because we were initializing `memTable.logSeqNum` too early and setting it to the visible sequence number rather than the first sequence number in the WAL being replayed. This would result in an error during `Open` that looked like: pebble: batch seqnum 2 is less than memtable creation seqnum 3
ed80277
to
213ca72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 5 files at r1, 4 of 4 files at r2.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @sumeerbhola)
TFTR! |
The addition of
memTable.logSeqNum
broke WAL replay in read-only modebecause we were initializing
memTable.logSeqNum
too early and settingit to the visible sequence number rather than the first sequence number
in the WAL being replayed. This would result in an error during
Open
that looked like: