From 8b1531b98f0d40bcd13edad89de8f7fb2cac0871 Mon Sep 17 00:00:00 2001 From: Wan Shen Lim Date: Mon, 11 Jun 2018 14:51:58 -0400 Subject: [PATCH] treat txn w/ no modifying queries as read-only (#1396:4) --- .../timestamp_ordering_transaction_manager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/concurrency/timestamp_ordering_transaction_manager.cpp b/src/concurrency/timestamp_ordering_transaction_manager.cpp index f3886ce9c4e..d3ece6e2cb9 100644 --- a/src/concurrency/timestamp_ordering_transaction_manager.cpp +++ b/src/concurrency/timestamp_ordering_transaction_manager.cpp @@ -623,6 +623,14 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction( //// handle other isolation levels ////////////////////////////////////////////////////////// + auto &rw_set = current_txn->GetReadWriteSet(); + + // if no modifying queries, treat as read-only + if (rw_set.empty()) { + EndTransaction(current_txn); + return ResultType::SUCCESS; + } + auto storage_manager = storage::StorageManager::GetInstance(); auto &log_manager = logging::LogManager::GetInstance(); @@ -631,7 +639,6 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction( // generate transaction id. cid_t end_commit_id = current_txn->GetCommitId(); - auto &rw_set = current_txn->GetReadWriteSet(); auto &rw_object_set = current_txn->GetCreateDropSet(); auto gc_set = current_txn->GetGCSetPtr();