@@ -76,6 +76,8 @@ void TransactionContext::Init(const size_t thread_id,
76
76
77
77
thread_id_ = thread_id;
78
78
79
+ is_written_ = false ;
80
+
79
81
isolation_level_ = isolation;
80
82
81
83
gc_set_ = std::make_shared<GCSet>();
@@ -115,18 +117,18 @@ void TransactionContext::RecordUpdate(const ItemPointer &location) {
115
117
(rw_set_[location] != RWType::DELETE &&
116
118
rw_set_[location] != RWType::INS_DEL));
117
119
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 ;
123
124
}
124
- rw_set_[location] = RWType::UPDATE ;
125
+ PELOTON_ASSERT (is_written_) ;
125
126
}
126
127
127
128
void TransactionContext::RecordInsert (const ItemPointer &location) {
128
129
PELOTON_ASSERT (rw_set_.find (location) == rw_set_.end ());
129
130
rw_set_[location] = RWType::INSERT;
131
+ is_written_ = true ;
130
132
}
131
133
132
134
bool TransactionContext::RecordDelete (const ItemPointer &location) {
@@ -135,10 +137,12 @@ bool TransactionContext::RecordDelete(const ItemPointer &location) {
135
137
rw_set_[location] != RWType::INS_DEL));
136
138
auto rw_set_it = rw_set_.find (location);
137
139
if (rw_set_it != rw_set_.end () && rw_set_it->second == RWType::INSERT) {
140
+ PELOTON_ASSERT (is_written_);
138
141
rw_set_it->second = RWType::INS_DEL;
139
142
return true ;
140
143
} else {
141
144
rw_set_[location] = RWType::DELETE;
145
+ is_written_ = true ;
142
146
return false ;
143
147
}
144
148
}
0 commit comments