Level / classic-level

An abstract-level database backed by LevelDB.
MIT License
58 stars 12 forks source link

Are writes ordered? #29

Closed ronag closed 1 year ago

ronag commented 2 years ago

I see that we are using napi_create_async_work. However, I can't read anywhere whether or not work items are guaranteed to be executed in order or not. If not then we might have a problem with write ordering, i.e. preceding writes overwriting following writes.

Do we need to create our own per db ordered work queue?

vweevers commented 2 years ago

Writes are not ordered (at least by design, and I doubt that napi_create_async_work is ordered, seeing as its purpose is parallel work). For the majority of users that's perfectly fine. Introducing a work queue would be a major change, and quite complicated, so I want to see many upvotes before considering it. Until then it can be handled in userland, where you have a choice of doing things in parallel or sequentially.

ronag commented 2 years ago

I think we might need to add a clear warning for this in the docs. I for one assumed that they would be ordered.

vweevers commented 2 years ago

That would be good. PR welcome.

vweevers commented 1 year ago

Done as part of https://github.com/Level/abstract-level/pull/42.