File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -469,9 +469,19 @@ bool DataTable::InsertInIndexes(const AbstractTuple *tuple,
469
469
470
470
// Handle failure
471
471
if (res == false ) {
472
- // If some of the indexes have been inserted,
473
- // the pointer has a chance to be dereferenced by readers and it cannot be
474
- // deleted
472
+ // if an index insert fails, undo all prior inserts on this index
473
+ for (index_itr = index_itr + 1 ; index_itr < index_count; ++index_itr) {
474
+ index = GetIndex (index_itr);
475
+ if (index == nullptr ) continue ;
476
+ index_schema = index ->GetKeySchema ();
477
+ indexed_columns = index_schema->GetIndexedColumns ();
478
+ std::unique_ptr<storage::Tuple> delete_key (
479
+ new storage::Tuple (index_schema, true ));
480
+ delete_key->SetFromTuple (tuple, indexed_columns, index ->GetPool ());
481
+ UNUSED_ATTRIBUTE bool delete_res =
482
+ index ->DeleteEntry (delete_key.get (), *index_entry_ptr);
483
+ PELOTON_ASSERT (delete_res == true );
484
+ }
475
485
*index_entry_ptr = nullptr ;
476
486
return false ;
477
487
} else {
You can’t perform that action at this time.
0 commit comments