Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usefulness of batch #36

Closed
reynir opened this issue Oct 31, 2022 · 1 comment
Closed

Usefulness of batch #36

reynir opened this issue Oct 31, 2022 · 1 comment

Comments

@reynir
Copy link
Member

reynir commented Oct 31, 2022

I was recently reviewing code by @dinosaure that implements Mirage_kv.RW, and there were some differences between the implementation and the behavior prescribed by the documentation in mirage-kv (see the thread).

The documentation is very precise in describing the behavior of batch which I think in general is a good thing. However, I think the behavior can be difficult to achieve in many implementations. It also mandates a default retries value of 13 - which may be undesirably high in many implementations. There seems to be a contradiction as well: It says:

Concurrent operations will not affect other ones executed during the batch.

And then the next line says

Batch applications can fail to apply if other operations are happening concurrently.

I am not sure how to read this, but if concurrent operations do not affect others during a batch then they shouldn't make the batch fail, or?

mirage-kv/src/mirage_kv.mli

Lines 251 to 264 in c66cf9d

val batch: t -> ?retries:int -> (t -> 'a Lwt.t) -> 'a Lwt.t
(** [batch t f] run [f] in batch. Ensure the durability of
operations.
Since a batch is applied at once, the readings inside a batch
will return the state before the entire batch. Concurrent
operations will not affect other ones executed during the batch.
Batch applications can fail to apply if other operations are
happening concurrently. In case of failure, [f] will run again
with the most recent version of [t]. The result is
[Error `Too_many_retries] if [f] is run for more then [retries] attemps
(default is [13]). *)

I reviewed a couple of implementations found through opam list --depends-on mirage-kv: fat-filesystem, chamelon, tar-mirage, irmin-mirage-git and git-kv (which was pinned on my computer)

Since no one seems to implement batch exactly as described I think we should consider changing or loosening the requirements of implementations or just remove batch altogether.

hannesm added a commit to hannesm/mirage-kv that referenced this issue Dec 1, 2022
@hannesm
Copy link
Member

hannesm commented Dec 3, 2022

Thanks for raising your concerns. in the previous mirage meeting we settled to remove batch from the interface (done in #37). Any kv implementation can just extend the interface with that functionality.

@hannesm hannesm closed this as completed Dec 3, 2022
hannesm added a commit to hannesm/opam-repository that referenced this issue Dec 12, 2022
CHANGES:

* Use ptime directly for RO.last_modified, instead of the int * int64 pair
  (mirage/mirage-kv#34)
* Add RW.allocate to allocate a key and fill it with zero bytes (mirage/mirage-kv#34)
* RO.list: return Key.t instead of string (mirage/mirage-kv#37, fixes mirage/mirage-kv#33)
* Introduce a custom error for RW.rename with a source which is a prefix of
  destination (mirage/mirage-kv#37, fixes mirage/mirage-kv#31)
* Use Optint.Int63.t for RO.size, RO.get_partial, RO.set_partial (mirage/mirage-kv#37, fixes mirage/mirage-kv#32)
* Remove RW.batch (mirage/mirage-kv#37, fixes mirage/mirage-kv#29 mirage/mirage-kv#36, discussed at the MirageOS meeting in
  November, and on the mirageos-devel mailing list in January 2022)
* Key.pp: escape the entire string, not individual fragments (mirage/mirage-kv#35)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants