private void UndoLog() { if (!Database.Get().TransactionManager.IsTransactionActive) { return; } List <LogRecordTable> logRecordsToBeUndone = GetLogToBeUndone(); List <LogRecordUndo> logRecordsUndone = GetUndoneLog(); // Do not undo log records we have undone on the previous recovery. // foreach (LogRecordUndo logRecordUndo in logRecordsUndone) { LogRecordTable logRecordToBeUndone = logRecordsToBeUndone.First(); if (!logRecordUndo.LogRecordTable.Equals(logRecordToBeUndone)) { throw new Exception("We did not undo properly the last time around."); } logRecordsToBeUndone.RemoveAt(0); } // Undo log. // foreach (LogRecordTable logRecord in logRecordsToBeUndone) { LogRecordUndo logRecordUndo = new LogRecordUndo(logRecord); PersistLogRecord(logRecordUndo); logRecordUndo.Redo(); } // Complete the transaction so we can open a new one later. // Also, this would be signal on the recovery not to undo this part of the log again. // Database.Get().TransactionManager.EndTransaction(); }
public abstract void UndoRowOperation(LogRecordUndo logRecordUndo, Table table);
public override void Undo(LogRecordUndo logRecordUndo) { UndoRowOperation(logRecordUndo, GetTable()); }