From 56154216b77ecf797bc54857c11c4ba6c9598b42 Mon Sep 17 00:00:00 2001 From: Wilson Wang Date: Mon, 3 May 2021 10:19:33 -0700 Subject: [PATCH] update variable declaration location --- server/mvcc/kvstore_txn.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/mvcc/kvstore_txn.go b/server/mvcc/kvstore_txn.go index 7b170ff01..287d2a944 100644 --- a/server/mvcc/kvstore_txn.go +++ b/server/mvcc/kvstore_txn.go @@ -35,11 +35,13 @@ type storeTxnRead struct { } func (s *store) Read(mode ReadTxMode, trace *traceutil.Trace) TxnRead { - var tx backend.ReadTx s.mu.RLock() s.revMu.RLock() - // backend holds b.readTx.RLock() only when creating the concurrentReadTx. After - // ConcurrentReadTx is created, it will not block write transaction. + // For read-only workloads, we use shared buffer by copying transaction read buffer + // for higher concurrency with ongoing blocking writes. + // For write/write-read transactions, we use the shared buffer + // rather than duplicating transaction read buffer to avoid transaction overhead. + var tx backend.ReadTx if mode == ConcurrentReadTxMode { tx = s.b.ConcurrentReadTx() } else {