Skip to content

Commit 53d157f

Browse files
committed
Add per-key version-locked writes to FfiDynStore
Introduce FfiDynStoreInner with per-key write version locks that ensure write ordering and skip stale versions in both sync and async code paths. Refactor build_with_store Test changes: - Unify tier store test helpers to use TestSyncStore for all tiers, replacing mixed SqliteStore/FilesystemStore/TestStore usage that caused test hangs due to TestStore's async write blocking
1 parent 467e647 commit 53d157f

File tree

6 files changed

+516
-182
lines changed

6 files changed

+516
-182
lines changed

src/builder.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,13 @@ impl NodeBuilder {
818818
/// [`set_backup_store`]: Self::set_backup_store
819819
pub fn build_with_store<S: SyncAndAsyncKVStore + Send + Sync + 'static>(
820820
&self, node_entropy: NodeEntropy, kv_store: S,
821+
) -> Result<Node, BuildError> {
822+
let primary_store: Arc<DynStore> = Arc::new(DynStoreWrapper(kv_store));
823+
self.build_with_dynstore(node_entropy, primary_store)
824+
}
825+
826+
fn build_with_dynstore(
827+
&self, node_entropy: NodeEntropy, primary_store: Arc<DynStore>,
821828
) -> Result<Node, BuildError> {
822829
let logger = setup_logger(&self.log_writer_config, &self.config)?;
823830

@@ -831,7 +838,6 @@ impl NodeBuilder {
831838
};
832839

833840
let ts_config = self.tier_store_config.as_ref();
834-
let primary_store: Arc<DynStore> = Arc::new(DynStoreWrapper(kv_store));
835841
let mut tier_store =
836842
TierStore::new(primary_store, Arc::clone(&runtime), Arc::clone(&logger));
837843
if let Some(config) = ts_config {
@@ -1306,8 +1312,8 @@ impl ArcedNodeBuilder {
13061312
pub fn build_with_store(
13071313
&self, node_entropy: Arc<NodeEntropy>, kv_store: Arc<FfiDynStore>,
13081314
) -> Result<Arc<Node>, BuildError> {
1309-
let store = DynStoreRef(kv_store as Arc<DynStore>);
1310-
self.inner.read().unwrap().build_with_store(*node_entropy, store).map(Arc::new)
1315+
let store = kv_store as Arc<DynStore>;
1316+
self.inner.read().unwrap().build_with_dynstore(*node_entropy, store).map(Arc::new)
13111317
}
13121318
}
13131319

0 commit comments

Comments
 (0)