https://slatedb.io logo
WAL vs. memtable flushing
# general
j
Copy code
WARN slatedb::batch_write: First write not durable after 5 seconds and WAL is disabled. SlateDB does not automatically flush memtables until `l0_sst_size_bytes` is reached. If writer is single threaded or has low throughput, the applications must call `flush` to ensure durability in a timely manner.
c
Yea I added this log line because everyone that disables the WAL hits this oddity.
The
flush.interval
does not apply to the memtable--only the WAL.
So there is nothing that automatically flushes writes in a timely interval.
The only trigger for a memtable flush is if flush() is called manually or if the l0 max size bytes is reached.
We debated a bit about what the right thing to do here was.. I had a PR that made flush.interval apply to the memtable when WAL was disabled.
The downside to that approach is that it could fill up l0_max_ssts very quickly, which would create back pressure until the compactor kicks in
I acknowledge it's not great... I rather feel like we should just default flush.interval to memtables if WAL is disabled.. @dmvk @Rohan were more on the fence about that.
j
ahh yeah. that makes sense. ok. sorry for finding all these little things. I wanna be sure about what I am getting into 🙂
it does feel like a footgun though. people calling
write
expect that to be fast
and flush to be slow 😄
at least... I do
p
Hmm I don't know in the context of databases
INSERT is fast, commit is slow
j
I'm writing a batch, isn't that like an insert with many items? 🙂
p
You still need a transaction in proper database servers
Even with a single statement
j
yes
I think fjall figured a good API. it does work differently depending on what durability you set on the batch: https://docs.rs/fjall/latest/fjall/struct.Batch.html#method.durability I might have the wrong read on it! I think if I set
await_durable: true
, I would expect it to flush right then and there. if set to false, then would this even need to be an async operation?
p
What's the gain? It'd be ugly to have insert_sync and insert_async
j
or
write
and
async fn write_durable
high throughput writing would benefit from not going through the whole async runtime. LSMs are generally built for high write throughput
I don't care that much tbh, I'm just talking through possibilities. I find the boundaries and behaviours confusing. I would certainly not expect a writebatch waiting indefinitely, by default, if the wal is disabled. then again, disabling the wal is a special feature, but it doesn't sound too uncommon.
p
Sounds like a micro-micro optimization to me...
j
it's an optimization, I'm pretty sure it's a big one on a hot path. the current performance is likely fine for me though, I don't care too much about that. I'm mostly surprised by the footgun here.
p
> LSMs are generally built for high write throughput Not sure if that's really true, they are far from being the most efficient data structure for that
They have nice properties but efficiency? Certainly not ;P
> I'm pretty sure it's a big one on a hot path You'd be bottlenecked by your IO throughput way before that anyway
c
We went back and forth a lot about this API in https://github.com/slatedb/slatedb/pull/260.
write_durable
vs
write
(sync) was discussed at some point. IMO it's cleaner to have one API that's async vs write() that's sync and write_durable that's async. But it's definitely subjective.
As for PersistMode,
WriteOptions
will grow some of this stuff as @flaneur233 works on txns I think.