Skip to content

Commit

Permalink
Cherry-pick GC fixes from cmu-db#1349, final part. Passes all tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbutrovich committed Jul 3, 2018
1 parent fe15d74 commit ba33991
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/storage/data_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,19 @@ bool DataTable::InsertInIndexes(const AbstractTuple *tuple,

// Handle failure
if (res == false) {
// If some of the indexes have been inserted,
// the pointer has a chance to be dereferenced by readers and it cannot be
// deleted
// if an index insert fails, undo all prior inserts on this index
for (index_itr = index_itr + 1; index_itr < index_count; ++index_itr) {
index = GetIndex(index_itr);
if (index == nullptr) continue;
index_schema = index->GetKeySchema();
indexed_columns = index_schema->GetIndexedColumns();
std::unique_ptr<storage::Tuple> delete_key(
new storage::Tuple(index_schema, true));
delete_key->SetFromTuple(tuple, indexed_columns, index->GetPool());
UNUSED_ATTRIBUTE bool delete_res =
index->DeleteEntry(delete_key.get(), *index_entry_ptr);
PELOTON_ASSERT(delete_res == true);
}
*index_entry_ptr = nullptr;
return false;
} else {
Expand Down

0 comments on commit ba33991

Please sign in to comment.