From 8920161bfb3816390b52d4c75bc3b43fc45f7174 Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Tue, 4 Jul 2023 12:01:59 +0200 Subject: [PATCH] Store: sync floating block indexes --- src/lib_store/unix/floating_block_store.ml | 7 ++++++- src/lib_store/unix/floating_block_store.mli | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib_store/unix/floating_block_store.ml b/src/lib_store/unix/floating_block_store.ml index 36ae46b368b4..b8bac28b4f44 100644 --- a/src/lib_store/unix/floating_block_store.ml +++ b/src/lib_store/unix/floating_block_store.ml @@ -39,6 +39,7 @@ type t = { fd : Lwt_unix.file_descr; kind : floating_kind; scheduler : Lwt_idle_waiter.t; + readonly : bool; } type info = { @@ -63,6 +64,9 @@ let mem floating_store hash = Lwt.return (Floating_block_index.mem floating_store.floating_block_index hash)) +let may_sync {floating_block_index; readonly; _} = + if readonly then Floating_block_index.sync floating_block_index + let find_info floating_store hash = Lwt_idle_waiter.task floating_store.scheduler (fun () -> try @@ -490,7 +494,8 @@ let init chain_dir ~readonly kind = (Naming.dir_path floating_index_dir) in let scheduler = Lwt_idle_waiter.create () in - return {floating_block_index; fd; floating_blocks_dir; kind; scheduler} + return + {floating_block_index; fd; floating_blocks_dir; kind; scheduler; readonly} let close {floating_block_index; fd; scheduler; _} = let open Lwt_syntax in diff --git a/src/lib_store/unix/floating_block_store.mli b/src/lib_store/unix/floating_block_store.mli index 7b097f349e68..34a88a543c22 100644 --- a/src/lib_store/unix/floating_block_store.mli +++ b/src/lib_store/unix/floating_block_store.mli @@ -90,6 +90,12 @@ val kind : t -> floating_kind [floating_store]. *) val mem : t -> Block_hash.t -> bool Lwt.t +(** [may_sync floating_store] updates a RO index instance to allow + concurrent access to the value added by a RW instance. This + operation is expected to be cheap (~10us) and has no effect on RW + instances. *) +val may_sync : t -> unit + (** [find_info floating_store block_hash] reads from the index the info of [block_hash] if the block is stored in [floating_store], returns [None] otherwise. *) -- GitLab