https://slatedb.io logo
hi, this pull request is still far away from being...
# general
f
hi, this pull request is still far away from being ready, but I wanted to check whether I'm on the right track or not 😯 https://github.com/slatedb/slatedb/pull/519 this PR extracts a WAL buffer manager to handle the lifecycle of in-memory WALs, including appending, flushing, and scanning. it tries to expose minimal apis over in-memory WALs, while encapsulating all the maintenance operations around in-memory WALs within the local states & local background task, which may help reduce the complexity of the global db state, and make it easier to having unit tests around the WAL buffer management itself. after this refactor, it's expected to be trivial to have sync commit supported like an if-else check in the commit pipeline. i'm a bit concerned that this approach might not aligned with the existing convention of keeping the states within the db state struct. i would appreciate any suggestions or feedback regarding this style 😯 .
c
> i'm a bit concerned that this approach might not aligned with the existing convention of keeping the states within the db state struct I'm a bit torn on this one.. I really like the logical structure of the wal buffer manager. It centralizes the wal state and read/write logic all in one place. That's very intuitive. OTOH, some of the stuff in the state I think might end up in the manifest.. having a single place that atomically/safely updates that stuff seems nice... 🤔 @Rohan can you weigh in with your philosophy on db_state? It has manifest stuff + a bunch of other random things as well.
I remember us discussing this a long while back, but don't recall the outcome
If it were just the in-memory buffer, I'd be more comfortable. But things like
last_flushed_wal_id
... 🤔
That has to go in the manifest, right?
Ah, nm, that's wal_id_last_seen...
Hmm..
f
i still need to explore ways to organize this part. however, if we don't hate the idea of centralizing the wal buffer management in one place, i'd like to continue explore further on this path, though it might fail in the end 😁
> But things like last_flushed_wal_id ... 🤔 > That has to go in the manifest, right? > Ah, nm, that's wal_id_last_seen... the last seen wal id can be read from manifest once started up, and read it later from the wal buffer manager whenever manifest need to be persisted i think 🤔
last_flushed_wal_id
can be regarded as a pure local state of the flusher i suppose, the other components do not really require this detail 😯
r
> OTOH, some of the stuff in the state I think might end up in the manifest.. having a single place that atomically/safely updates that stuff seems nice... 🤔 this was the main reasoning for keeping everything in db_state. It's easier to synchronize and reason about if the state is centralized - especially all the state related to the manifest. But wal flushing feels like it can be broken out, and it's fairly complex so I like this design. One concern I have - we're not tying the semantics we talked about in RFC-8 to the wal right? I don't see any reason we need to. On both the write and read side the semantics just require maintaining watermarks about what's durable/committed, which doesn't rely on the wal. The wal is just an optimization to bring down the write latency while managing cost.
f
wal buffer management is not planned to contain the replay part in the pr, it only serves the dirty reads in RFC-8, when we want to scan the unflushed in memory WALs with watermarks. it can also be implemented as put everything inside memtable and filter by seq watermark, i plans have PoCs over these two approaches in this pr: 1. use WAL for dirty read; 2. apply to memtable as soon as possible and control a committed watermark to it. (i reread pebble's commit pipeline design it seems they are kinda resembles with the second approach, which have the benefits that allowing them to update the memtable in a batch without a lock, just bump the committed seq atomatically 😯) it does not require to contain the scan part if we take the 2nd approach for dirty read, which looks pretty reasonable.
> But wal flushing feels like it can be broken out, and it's fairly complex so I like this design. thank you for this. my concern is that when local WAL flushing comes in, the complexities around flushing will increase a lot 😯 , so having a standalone manager extracted may help us put borders around the complexities without requiring another module to notice it.