komora-io / marble

garbage-collecting on-disk object store, supporting higher level KV stores and databases.
Apache License 2.0
352 stars 12 forks source link

What does non-runtime-atomicity of Marble::write_batch imply? #9

Open vi opened 1 year ago

vi commented 1 year ago

This function is crash-atomic but NOT runtime atomic. If you are concurrently serving reads, and require atomic batch semantics, you should serve reads out of an in-memory cache until this function returns.

spacejam commented 1 year ago

previous db: 1: a 2: b

write batch sets these to: 1: x 2: y

then it is conceivable that reads concurrent to that write batch could observe either a or x for 1, or b or y for 2. but no tears. no unrelated keys are impacted. None can not be returned for reads that begin after the initial values are written.

that said, I'm hacking on a simple MVCC implementation today that might avoid this confusion completely.