From 02514da469cc569a55fb357589ffcdff59a76b82 Mon Sep 17 00:00:00 2001 From: mbutrovich Date: Tue, 3 Jul 2018 18:05:33 -0400 Subject: [PATCH] Allow reads of committed, visible tuples even if the write lock is held as long as reader's TS < writer's TS. --- .../timestamp_ordering_transaction_manager.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/concurrency/timestamp_ordering_transaction_manager.cpp b/src/concurrency/timestamp_ordering_transaction_manager.cpp index 1deeccd0609..ff7067dcf70 100644 --- a/src/concurrency/timestamp_ordering_transaction_manager.cpp +++ b/src/concurrency/timestamp_ordering_transaction_manager.cpp @@ -29,17 +29,21 @@ namespace concurrency { bool TimestampOrderingTransactionManager::SetLastReaderCommitId( const storage::TileGroupHeader *const tile_group_header, - const oid_t &tuple_id, const cid_t ¤t_cid, const bool is_owner) { + const oid_t &tuple_id, const cid_t ¤t_cid, UNUSED_ATTRIBUTE const bool is_owner) { // get the pointer to the last_reader_cid field. cid_t read_ts = tile_group_header->GetLastReaderCommitId(tuple_id); + if (current_cid <= read_ts) { + return true; + } + auto &latch = tile_group_header->GetSpinLatch(tuple_id); latch.Lock(); txn_id_t tuple_txn_id = tile_group_header->GetTransactionId(tuple_id); - if (is_owner == false && tuple_txn_id != INITIAL_TXN_ID) { + if (tuple_txn_id != INITIAL_TXN_ID && tuple_txn_id < current_cid) { // if the write lock has already been acquired by some concurrent // transactions, // then return without setting the last_reader_cid. @@ -323,14 +327,10 @@ bool TimestampOrderingTransactionManager::PerformRead(TransactionContext *const } } else { - // if the current transaction has already owned this tuple, - // then perform read directly. - PELOTON_ASSERT(tile_group_header->GetLastReaderCommitId(tuple_id) == - current_txn->GetCommitId() || - tile_group_header->GetLastReaderCommitId(tuple_id) == 0); + UNUSED_ATTRIBUTE bool ret = SetLastReaderCommitId( + tile_group_header, tuple_id, current_txn->GetCommitId(), true); - // this version must already be in the read/write set. - // so no need to update read set. + PELOTON_ASSERT(ret == true); return true; } }