Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 9f8acef

Browse files
committed
Use is_written_ flag instead of rwset in commit
1 parent 2c7cf9e commit 9f8acef

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/concurrency/timestamp_ordering_transaction_manager.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -623,15 +623,14 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction(
623623
//// handle other isolation levels
624624
//////////////////////////////////////////////////////////
625625

626-
auto &rw_set = current_txn->GetReadWriteSet();
627-
628-
// if no modifying queries, treat as read-only
629-
if (rw_set.empty()) {
630-
LOG_TRACE("Empty RW set, ending transaction.");
626+
if (!current_txn->IsWritten()) {
627+
LOG_TRACE("Transaction not yet written, ending transaction.");
631628
EndTransaction(current_txn);
632629
return ResultType::SUCCESS;
633630
}
634631

632+
auto &rw_set = current_txn->GetReadWriteSet();
633+
635634
auto storage_manager = storage::StorageManager::GetInstance();
636635
auto &log_manager = logging::LogManager::GetInstance();
637636

src/concurrency/transaction_context.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ void TransactionContext::RecordReadOwn(const ItemPointer &location) {
112112
(rw_set_[location] != RWType::DELETE &&
113113
rw_set_[location] != RWType::INS_DEL));
114114
rw_set_[location] = RWType::READ_OWN;
115+
is_written_ = true;
115116
}
116117

117118
void TransactionContext::RecordUpdate(const ItemPointer &location) {

src/include/concurrency/transaction_context.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ class TransactionContext : public Printable {
266266
*/
267267
bool IsReadOnly() const { return read_only_; }
268268

269+
/**
270+
* @brief Determines if already written.
271+
*
272+
* @return True if already written, False otherwise.
273+
*/
274+
bool IsWritten() const { return is_written_; }
275+
269276
/**
270277
* @brief Gets the isolation level.
271278
*

0 commit comments

Comments
 (0)