diff --git a/Cargo.toml b/Cargo.toml index 9c36a76805..38b749e7b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,7 +77,6 @@ clippy.print_stdout = "warn" clippy.print_stderr = "warn" clippy.dbg_macro = "warn" clippy.implicit_clone = "warn" -clippy.readonly_write_lock = "allow" rust.unknown_lints = "deny" rust.unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] } diff --git a/src/log-store/src/raft_engine/backend.rs b/src/log-store/src/raft_engine/backend.rs index 3d41e5298d..8d27994f8b 100644 --- a/src/log-store/src/raft_engine/backend.rs +++ b/src/log-store/src/raft_engine/backend.rs @@ -114,7 +114,13 @@ impl TxnService for RaftEngineBackend { } = txn.into(); let mut succeeded = true; + + // Here we are using the write lock to guard against parallel access inside "txn", and + // outside "get" or "put" etc. It doesn't serve the purpose of mutating some Rust data, so + // the variable is not "mut". Suppress the clippy warning because of this. + #[allow(clippy::readonly_write_lock)] let engine = self.engine.write().unwrap(); + for cmp in compare { let existing_value = engine_get(&engine, &cmp.key)?.map(|kv| kv.value); if !cmp.compare_value(existing_value.as_ref()) {