https://slatedb.io logo
๐Ÿ‘‹I'm trying to plan out the golang WAL implementa...
# general
t
๐Ÿ‘‹I'm trying to plan out the golang WAL implementation to support transactions, snapshots and the merge operator. I'm currently learning about Merge Operators. My understanding is that a "merge" error could occur during: write, compaction or read. Returning an error to the user on write and read is straightforward enough. However I have two questions. - If an error occurs during write, will the merge OP be persisted in the WAL or does the error indicate the put failed and is not persisted in the WAL. - According to the RFC, If a merge error occurs during compaction the OP remains uncompacted such that it can be "retried". If the retry never succeeds, the OP continues to exist in the SST as an unmerged entry. Is there any process available to remove the offending OP? Is it expected the offending OP will continue until the key is removed?
c
Little tied up at the moment but @dmvk is working on this and probably will be the best source
> Is there any process available to remove the offending OP? Yes, the offending op can be handled by updating the merge function so that it no longer throws an error. The updated logic can choose to drop the bad op, modify it as needed, or do anything else deemed appropriate. > Is it expected the offending OP will continue until the key is removed? Yes. > If an error occurs during write, will the merge OP be persisted in the WAL or does the error indicate the put failed and is not persisted in the WAL. Not 100% sure what you mean here. The merge operator is applied on read. There is one exception, I believe, which is if there are multiple merge operator writes in memory for the same ke (KVTable for WAL or memtable). In this case, the merge operation will happen in memory if possible, so we have fewer merge writes to put on disk. If the operators can't be merged there due to error, I believe we will keep both records separately and write them to disk separately, the same as in the compaction scenario.
cc @dmvk it might be good to clarify this a bit in the RFC (and correct me if I'm wrong)
d
There is a section about error handling already.
Error can happen both on read and on write, but on the write path itโ€™s really hard to bubble the error up to the user, so we simply persist unmerged entries as they are. There are several places where we might try to merge on the write path (write batch, memtable, l0 flush, compaction).
On read path, we simply propagate the error up to the user.
t
> so we simply persist unmerged entries as they are This was the clarification I was missing. I didn't see this in the RFC - I probably missed it - thank you all!