org.h2.mvstore.tx.RollbackDecisionMaker Maven / Gradle / Ivy
/*
* Copyright 2004-2021 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (https://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.mvstore.tx;
import org.h2.mvstore.MVMap;
import org.h2.value.VersionedValue;
/**
* Class RollbackDecisionMaker process undo log record during transaction rollback.
*
* @author Andrei Tokar
*/
final class RollbackDecisionMaker extends MVMap.DecisionMaker> {
private final TransactionStore store;
private final long transactionId;
private final long toLogId;
private final TransactionStore.RollbackListener listener;
private MVMap.Decision decision;
RollbackDecisionMaker(TransactionStore store, long transactionId, long toLogId,
TransactionStore.RollbackListener listener) {
this.store = store;
this.transactionId = transactionId;
this.toLogId = toLogId;
this.listener = listener;
}
@SuppressWarnings({"unchecked","rawtypes"})
@Override
public MVMap.Decision decide(Record existingValue, Record providedValue) {
assert decision == null;
if (existingValue == null) {
// normally existingValue will always be there except of db initialization
// where some undo log entry was captured on disk but actual map entry was not
decision = MVMap.Decision.ABORT;
} else {
VersionedValue