h2/src/main/org/h2/mvstore/db/TransactionStore.java
/**
     * Rollback to an old savepoint.
     *
     * @param t the transaction
     * @param maxLogId the last log id
     * @param toLogId the log id to roll back to
     */
Rollback to an old savepoint.
@param t the transaction
@param maxLogId the last log id
@param toLogId the log id to roll back to
Rollback to an old savepoint . @param t the transaction @param maxLogId the last log id @param toLogId the log id to roll back to
void rollbackTo(Transaction t, long maxLogId, long toLogId) {
        synchronized (undoLog) {
            for (long logId = maxLogId - 1; logId >= toLogId; logId--) {
                Long undoKey = getOperationId(t.getId(), logId);
                Object[] op = undoLog.get(undoKey);
                if (op == null) {
                    undoKey = undoLog.floorKey(undoKey);
                    if (undoKey == null || getTransactionId(undoKey) != t.getId()) {
                        break;
                    }
                    logId = getLogId(undoKey) + 1;
                    continue;
                }
                int mapId = ((Integer) op[0]).intValue();
                MVMap<Object, VersionedValue> map = openMap(mapId);
                if (map != null) {
                    Object key = op[1];
                    VersionedValue oldValue = (VersionedValue) op[2];
                    if (oldValue == null) {
                        map.remove(key);
                    } else {
                        map.put(key, oldValue);
                    }
                }
                undoLog.remove(undoKey);
            }
        }
    }
void rollbackTo ( Transaction t , long maxLogId , long toLogId ) { synchronized ( undoLog ) { for ( long logId = maxLogId - 1 ; logId >= toLogId ; logId -- ) { Long undoKey = getOperationId ( t . getId ( ) , logId ) ; Object [ ] op = undoLog . get ( undoKey ) ; if ( op == null ) { undoKey = undoLog . floorKey ( undoKey ) ; if ( undoKey == null || getTransactionId ( undoKey ) != t . getId ( ) ) { break ; } logId = getLogId ( undoKey ) + 1 ; continue ; } int mapId = ( ( Integer ) op [ 0 ] ) . intValue ( ) ; MVMap < Object , VersionedValue > map = openMap ( mapId ) ; if ( map != null ) { Object key = op [ 1 ] ; VersionedValue oldValue = ( VersionedValue ) op [ 2 ] ; if ( oldValue == null ) { map . remove ( key ) ; } else { map . put ( key , oldValue ) ; } } undoLog . remove ( undoKey ) ; } } }
Rollback to an old savepoint.
Rollback to an old savepoint .
// TODO could synchronize on blocks (100 at a time or so) // partially rolled back: load previous // this transaction added the value // this transaction updated the value