Skip to content

Commit

Permalink
refactoring write-recording/rollback and rogging/recovery of Update (…
Browse files Browse the repository at this point in the history
…2): WIP.
  • Loading branch information
ryogrid committed Jun 11, 2024
1 parent 7bf09aa commit 1f07904
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 4 additions & 1 deletion lib/recovery/log_recovery/log_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ func (log_recovery *LogRecovery) Undo(txn *access.Transaction) bool {
page_ :=
access.CastPageAsTablePage(log_recovery.buffer_pool_manager.FetchPage(log_record.Update_rid.GetPageId()))
_, err, _ := page_.UpdateTuple(&log_record.Old_tuple, nil, nil, &log_record.New_tuple, &log_record.Update_rid, txn, nil, log_recovery.log_manager)
if err != nil {
// note: when error is ErrNotEnoughSpace, target operation is rollbacked with log of APPLYDELETE and INSERT
// so, we don't need to rollback it again
// this occurs RID changed in UPDATE operation at Abort phase
if err != nil && err != access.ErrNotEnoughSpace {
panic(fmt.Sprintln("UpdateTuple at rollback failed! err:", err))
}
log_recovery.buffer_pool_manager.UnpinPage(page_.GetPageId(), true)
Expand Down
13 changes: 7 additions & 6 deletions lib/storage/access/transaction_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,7 @@ func (transaction_manager *TransactionManager) Abort(catalog_ catalog_interface.
fmt.Printf("TransactionManager::Abort handle UPDATE write log. txn.txn_id:%v dbgInfo:%s rid:%v tuple1.Size()=%d \n", txn.txn_id, txn.dbgInfo, item.rid, item.tuple1.Size())
}

var is_updated = false
is_updated, _, _, _, _ = table.UpdateTuple(item.tuple1, nil, nil, item.oid, *item.rid, txn, true)
if !is_updated {
panic("UpdateTuple at rollback failed!")
}
_, new_rid, _, _, _ := table.UpdateTuple(item.tuple1, nil, nil, item.oid, *item.rid, txn, true)

// rollback is not needed at update
// (RID chaned case is handled at DELETE and INSERT write log handling)
Expand All @@ -210,7 +206,12 @@ func (transaction_manager *TransactionManager) Abort(catalog_ catalog_interface.
bfRlbkKeyVal := catalog_.GetColValFromTupleForRollback(item.tuple2, colIdx, item.oid)
rlbkKeyVal := catalog_.GetColValFromTupleForRollback(item.tuple1, colIdx, item.oid)
if !bfRlbkKeyVal.CompareEquals(*rlbkKeyVal) {
index_.UpdateEntry(item.tuple2, *item.rid, item.tuple1, *item.rid, txn)
if new_rid != nil {
// tuple location is changed on Abort stage
index_.UpdateEntry(item.tuple2, *item.rid, item.tuple1, *new_rid, txn)
} else {
index_.UpdateEntry(item.tuple2, *item.rid, item.tuple1, *item.rid, txn)
}
}
}
}
Expand Down

0 comments on commit 1f07904

Please sign in to comment.