https://slatedb.io logo
<@1144686022010097794> (cc <@1290758620664827966> ...
# general
a
@Rohan (cc @jason ) https://github.com/slatedb/slatedb/issues/431 is taking me for a bit of a spin with the mechanics of flushing the manifest. The goal would be for the
last_clock_tick
in the manifest to be the last durable clock tick, which is the greatest timestamp in
wal_id_last_seen
(or the greatest timestamp in L0 for wal_disabled). The problem is that
wal_id_last_seen
is updated on
freeze_wal
, not when the wal is flushed, so it's technically possible that a manifest is flushed with a
wal_id_last_seen
that's greater than the last durable WAL. So what I'm noticing is that there's a bit of a "drift" between the
CoreDbState
and the flushed manifest and I'm not totally sure how to reconcile it. One option is to add a
last_durable_clock_tick
and
last_durable_wal_id_seen
and those are the ones that make it into the manifest, and they're updated atomically after a WAL is flushed successfully, but that seems to add some complicated bookkeeping. Thoughts?
cc @flaneur233 because I think https://github.com/slatedb/slatedb/pull/389 might have similar issues when replaying seqnum from the WAL (I notice that you just set the seqnum to be the biggest seqnum seen in the WAL, but that means the manifest may actually have a seqnum in it that's not durable - IDK if that's a problem or not, but it seems like we would like to enforce the invariant that a manifest always have a valid seqnum)
f
yeah, manifest is expected to be only updated whenever any data files are modified (l0 flushes, compactions, etc). and is considered not frequently updated. seqnum is increased along with new data inserts (and writing to WAL), but while data files are being inserted, the data files may not have been changed together unless memtable get flushed to L0.
> the problem is that wal_id_last_seen is updated on freeze_wal, not when the wal is flushed, so it's technically possible that a manifest is flushed with a wal_id_last_seen that's greater than the last durable WAL. oh this might be bad...
r
Yeah this seems to be a bug. I think if it's triggered (e.g. we write out a manifest with a
wal_id_last_seen
that's greater than the last flushed manifest and then crash and restart, then we'll actually crash when recovering because we assert that we have all the wals up to
wal_id_last_seen
> So what I'm noticing is that there's a bit of a "drift" between the CoreDbState and the flushed manifest not sure I follow - you mean between the manifest and the WAL?
I think the right thing to do is to update the clock tick and last wal id in
CoreDbState
only when a wal id (or memtable) is flushed, and to track them for the db outside of
CoreDbState
for the clock, maybe it makes sense to only update the core db state when writing an l0 file with the last clock tick in that l0 file. That way, when you replay the wal it's natural to update the clock as you replay records
f
yeah, this resemebles with the approach seqnum takes
"only save manifest file on l0/sst updated" gives a straghtforward mindset.
a
https://github.com/slatedb/slatedb/issues/433 OK I created a ticket for this