@@ -76,6 +76,8 @@ void TransactionContext::Init(const size_t thread_id,
7676
7777 thread_id_ = thread_id;
7878
79+ is_written_ = false ;
80+
7981 isolation_level_ = isolation;
8082
8183 gc_set_ = std::make_shared<GCSet>();
@@ -115,18 +117,18 @@ void TransactionContext::RecordUpdate(const ItemPointer &location) {
115117 (rw_set_[location] != RWType::DELETE &&
116118 rw_set_[location] != RWType::INS_DEL));
117119 auto rw_set_it = rw_set_.find (location);
118- if (rw_set_it != rw_set_.end ()) {
119- if (rw_set_it->second == RWType::READ || rw_set_it->second == RWType::READ_OWN) {
120- rw_set_it->second = RWType::UPDATE;
121- }
122- return ;
120+ if (rw_set_it != rw_set_.end () && (rw_set_it->second == RWType::READ ||
121+ rw_set_it->second == RWType::READ_OWN)) {
122+ rw_set_it->second = RWType::UPDATE;
123+ is_written_ = true ;
123124 }
124- rw_set_[location] = RWType::UPDATE ;
125+ PELOTON_ASSERT (is_written_) ;
125126}
126127
127128void TransactionContext::RecordInsert (const ItemPointer &location) {
128129 PELOTON_ASSERT (rw_set_.find (location) == rw_set_.end ());
129130 rw_set_[location] = RWType::INSERT;
131+ is_written_ = true ;
130132}
131133
132134bool TransactionContext::RecordDelete (const ItemPointer &location) {
@@ -135,10 +137,12 @@ bool TransactionContext::RecordDelete(const ItemPointer &location) {
135137 rw_set_[location] != RWType::INS_DEL));
136138 auto rw_set_it = rw_set_.find (location);
137139 if (rw_set_it != rw_set_.end () && rw_set_it->second == RWType::INSERT) {
140+ PELOTON_ASSERT (is_written_);
138141 rw_set_it->second = RWType::INS_DEL;
139142 return true ;
140143 } else {
141144 rw_set_[location] = RWType::DELETE;
145+ is_written_ = true ;
142146 return false ;
143147 }
144148}
0 commit comments