org.apache.ignite.internal.processors.cache.transactions

## Class IgniteTxManager

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter
  - - org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager

All Implemented Interfaces:
  GridCacheSharedManager

    public class IgniteTxManager
    extends GridCacheSharedManagerAdapter

Cache transaction manager.

### Nested Class Summary

Nested Classes
`class` `IgniteTxManager.TxDumpsThrottling` This class is used to store information about transaction time dump throttling.

### Field Summary

Fields
`static Predicate<TxRecord>` `COMPLETED_TX_STATES` Returns `true` if transaction has completed states.
`static int` `DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT` One phase commit deferred ack request timeout.
`static int` `DFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_BUFFER_SIZE`
`static int` `DFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT`
`static int` `DFLT_DUMP_TX_COLLISIONS_INTERVAL`
`static int` `DFLT_MAX_COMPLETED_TX_CNT` Default maximum number of transactions that have completed.
`static int` `DFLT_SLOW_TX_WARN_TIMEOUT`
`static int` `DFLT_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT`
`static int` `DFLT_TX_DEADLOCK_DETECTION_MAX_ITERS`
`static boolean` `DFLT_TX_OWNER_DUMP_REQUESTS_ALLOWED`
`static Predicate<TxRecord>` `PREPARED_TX_STATES` Returns `true` if transaction has prepared states.
`static String` `TXS_MON_LIST`
`static String` `TXS_MON_LIST_DESC`

### Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter

`cctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`IgniteTxManager()`

### Method Summary

All Methods Instance Methods Concrete Methods
`Collection<IgniteInternalTx>` `activeTransactions()`
`void` `addAlternateVersion(GridCacheVersion ver, IgniteInternalTx tx)`
`void` `addCommittedTx(IgniteInternalTx tx)`
`boolean` `addCommittedTx(IgniteInternalTx tx, GridCacheVersion xidVer, @Nullable GridCacheVersion nearXidVer)`
`void` `addCommittedTxReturn(IgniteInternalTx tx, GridCacheReturnCompletableWrapper ret)`
`void` `addFuture(org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.TxDeadlockFuture fut)`
`boolean` `addRolledbackTx(IgniteInternalTx tx)`
`boolean` `addRolledbackTx(IgniteInternalTx tx, GridCacheVersion xidVer)`
`void` `checkEmptyTransactions(@NotNull IgniteOutClosure<String> errMsgConstructor)` Method checks that current thread does not have active transactions.
`void` `clearThreadMap(IgniteInternalTx tx)`
`void` `clearUncommitedStates()` Clears tx states collections.
`void` `collectTxStates(TxRecord txRec)` Collects tx states `TransactionState` for further correct restoring.
`int` `collisionsDumpInterval()` Returns tx keys collisions dump interval, for additional info check `IgniteSystemProperties.IGNITE_DUMP_TX_COLLISIONS_INTERVAL` description.
`void` `collisionsDumpIntervalDistributed(int collisionsDumpInterval)` Changes tx key collisions dump interval.
`IgniteInternalFuture<Boolean>` `commitIfPrepared(IgniteInternalTx tx, Set<UUID> failedNodeIds)` Commits transaction in case when node started transaction failed, but all related transactions were prepared (invalidates transaction if it is not fully prepared).
`void` `commitTx(IgniteInternalTx tx)` Commits a transaction.
`int` `completedVersionsSize()`
`boolean` `deadlockDetectionEnabled()`
`Collection<IgniteInternalFuture<?>>` `deadlockDetectionFutures()`
`IgniteInternalFuture<TxDeadlock>` `detectDeadlock(IgniteInternalTx tx, Set<IgniteTxKey> keys)` Performs deadlock detection for given keys.
`void` `detectPossibleCollidingKeys(GridDistributedCacheEntry entry)` Check local and remote candidates queue size.
`void` `enterNearTxSystemSection()` Enters system section for thread local near tx, if it is present.
`void` `fastFinishTx(GridNearTxLocal tx, boolean commit, boolean clearThreadMap)` Fast finish transaction.
`IgniteInternalFuture<?>` `finishAllTxs(IgniteInternalFuture<?> finishLocalTxsFuture, AffinityTopologyVersion topVer)` Creates a future that will wait for finishing all tx updates on backups after all local transactions are finished.
`IgniteInternalFuture<Boolean>` `finishLocalTxs(AffinityTopologyVersion topVer)` Creates a future that will wait for all ongoing transactions that maybe affected by topology update to be finished.
`void` `finishTxOnRecovery(IgniteInternalTx tx, boolean commit)` Commits or rolls back prepared transaction.
`void` `forgetTx(IgniteInternalTx tx)` Removes Tx from manager.
`@Nullable org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.TxDeadlockFuture` `future(long futId)`
`GridCacheReturnCompletableWrapper` `getCommittedTxReturn(GridCacheVersion xidVer)`
`DistributedTransactionConfiguration` `getDistributedTransactionConfiguration()`
`int` `idMapSize()`
`boolean` `inUserTx()`
`void` `leaveNearTxSystemSection()` Leaves system section for thread local near tx, if it is present.
`@Nullable IgniteTxLocalAdapter` `localTx()`
`@Nullable AffinityTopologyVersion` `lockedTopologyVersion(long threadId, IgniteInternalTx ignore)`
`long` `longOperationsDumpTimeout()`
`void` `longOperationsDumpTimeout(long longOpsDumpTimeout)`
`void` `longOperationsDumpTimeoutDistributed(long longOpsDumpTimeout)` Setting (for all nodes) a timeout (in millis) for printing long-running transactions as well as transactions that cannot receive locks for all their keys for a long time.
`void` `longTransactionTimeDumpSamplesPerSecondLimit(int limit)` Sets the limit of samples of completed transactions that will be dumped in log per second, if `transactionTimeDumpSamplesCoefficient()` is above `0.0`.
`long` `longTransactionTimeDumpThreshold()` Threshold timeout for long transactions, if transaction exceeds it, it will be dumped in log with information about how much time did it spent in system time (time while aquiring locks, preparing, commiting, etc) and user time (time when client node runs some code while holding transaction and not waiting it).
`void` `longTransactionTimeDumpThreshold(long longTransactionTimeDumpThreshold)` Sets threshold timeout for long transactions, if transaction exceeds it, it will be dumped in log with information about how much time did it spent in system time (time while aquiring locks, preparing, commiting, etc) and user time (time when client node runs some code while holding transaction and not waiting it).
`void` `longTransactionTimeDumpThresholdDistributed(long threshold)` Sets threshold timeout in milliseconds for long transactions, if transaction exceeds it, it will be dumped in log with information about how much time did it spent in system time (time while aquiring locks, preparing, commiting, etc.)
`GridCacheVersion` `mappedVersion(GridCacheVersion from)`
`void` `mvccFinish(IgniteTxAdapter tx)` Finishes MVCC transaction.
`<T extends IgniteInternalTx> T` `nearTx(GridCacheVersion txId)`
`boolean` `needWaitTransaction(IgniteInternalTx tx, AffinityTopologyVersion topVer)`
`GridNearTxLocal` `newTx(boolean implicit, boolean implicitSingle, @Nullable GridCacheContext sysCacheCtx, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, boolean storeEnabled, Boolean mvccOp, int txSize, @Nullable String lb, boolean tracingEnabled)`
`<T extends IgniteInternalTx> T` `onCreated(@Nullable GridCacheContext cacheCtx, T tx)`
`void` `onDisconnected(IgniteFuture reconnectFut)`
`protected void` `onKernalStart0(boolean active)`
`protected void` `onKernalStop0(boolean cancel)`
`boolean` `onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner)` Callback invoked whenever a member of a transaction acquires lock ownership.
`boolean` `onStarted(IgniteInternalTx tx)` Transaction start callback (has to do with when any operation was performed on this transaction).
`void` `onTxTimeoutOnPartitionMapExchangeChange(TxTimeoutOnPartitionMapExchangeChangeMessage msg)` Callback invoked from discovery thread when discovery custom message is received.
`Boolean` `peekCompletedVersionsHistory(GridCacheVersion xid)` Peeks completed versions history map to find out whether transaction was committed or rolled back in the recent past.
`void` `prepareTx(IgniteInternalTx tx, @Nullable Collection<IgniteTxEntry> entries)` Handles prepare stage.
`void` `printMemoryStats()` Prints out memory stats to standard out.
`void` `processTxTimeoutOnPartitionMapExchangeChange(TxTimeoutOnPartitionMapExchangeChangeMessage msg)` The task for changing transaction timeout on partition map exchange processed by exchange worker.
`void` `pushCollidingKeysWithQueueSize(GridCacheMapEntry key, int queueSize)` Collect queue size per key collisions info.
`IgniteInternalFuture<Boolean>` `recoverLocalTxs(AffinityTopologyVersion topVer, ClusterNode node)` Creates a future that will wait for all transactions with failed primary recovery.
`IgniteInternalFuture<?>` `remoteTxFinishFuture(GridCacheVersion nearVer)`
`void` `removeCommittedTx(IgniteInternalTx tx)`
`void` `removeFuture(long futId)`
`void` `removeTxReturn(GridCacheVersion xidVer)`
`void` `resetContext()` Commit ended.
`void` `resumeTx(GridNearTxLocal tx, long threadId)` Resume transaction in current thread.
`void` `rollbackOnTopologyChange(AffinityTopologyVersion topVer)` Rollback transactions blocking partition map exchange.
`void` `rollbackTransactionsForCache(int cacheId)`
`void` `rollbackTransactionsForStoppingCache(int cacheToStop)`
`void` `rollbackTx(IgniteInternalTx tx, boolean clearThreadMap, boolean skipCompletedVers)` Rolls back a transaction.
`void` `salvageTx(IgniteInternalTx tx)` Invalidates transaction.
`void` `sendDeferredAckResponse(UUID nodeId, GridCacheVersion ver)`
`void` `setMvccState(IgniteInternalTx tx, TransactionState state)` Sets MVCC state.
`void` `setTxOwnerDumpRequestsAllowed(boolean allowed)` Sets if dump requests from local node to near node are allowed, when long running transaction is found.
`void` `setTxOwnerDumpRequestsAllowedDistributed(boolean allowed)` Sets if dump requests from local node to near node are allowed, when long running transaction is found.
`void` `setTxTimeoutOnPartitionMapExchange(long timeout)` Sets transaction timeout on partition map exchange.
`boolean` `setTxTopologyHint(@Nullable AffinityTopologyVersion topVer)`
`int` `slowTxWarnTimeout()`
`void` `slowTxWarnTimeout(int slowTxWarnTimeout)`
`protected void` `start0()`
`protected void` `stop0(boolean cancel)`
`void` `suspendTx(GridNearTxLocal tx)` Suspends transaction.
`GridNearTxLocal` `threadLocalTx(GridCacheContext cctx)`
`int` `threadMapSize()`
`double` `transactionTimeDumpSamplesCoefficient()` The coefficient for samples of completed transactions that will be dumped in log.
`void` `transactionTimeDumpSamplesCoefficient(double transactionTimeDumpSamplesCoefficient)` Sets the coefficient for samples of completed transactions that will be dumped in log.
`void` `transactionTimeDumpSamplesCoefficientDistributed(double coefficient)` Sets the coefficient for samples of long running transactions that will be dumped in log, if `longTransactionTimeDumpThreshold()` is set to non-zero value."
`int` `transactionTimeDumpSamplesPerSecondLimit()` The limit of samples of completed transactions that will be dumped in log per second, if `transactionTimeDumpSamplesCoefficient()` is above `0.0`.
`void` `transactionTimeDumpSamplesPerSecondLimit(int transactionTimeDumpSamplesPerSecondLimit)` Sets the limit of samples of completed transactions that will be dumped in log per second, if `transactionTimeDumpSamplesCoefficient()` is above `0.0`.
`<T> T` `tx()`
`<T extends IgniteInternalTx> T` `tx(GridCacheVersion txId)`
`IgniteInternalTx` `tx(IgniteInternalTx tx)` Sets transaction for current thread.
`IgniteInternalFuture<Boolean>` `txCommitted(GridCacheVersion xidVer)`
`void` `txContext(IgniteInternalTx tx)`
`@Nullable GridCacheVersion` `txContextVersion()` Gets version of transaction in tx context or `null` if tx context is empty.
`IgniteTxHandler` `txHandler()`
`boolean` `txOwnerDumpRequestsAllowed()` Sets if dump requests from local node to near node are allowed, when long running transaction is found.
`@Nullable IgniteInternalFuture<Boolean>` `txsPreparedOrCommitted(GridCacheVersion nearVer, int txNum)` Checks if transactions with given near version ID was prepared or committed.
`boolean` `uncommitedTx(DataEntry dataEntry)`
`@Nullable GridNearTxLocal` `userTx()`
`IgnitePair<Collection<GridCacheVersion>>` `versions(GridCacheVersion min)`

### Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter

`context, isStopping, kernalStartInfo, kernalStopInfo, log, onKernalStart, onKernalStop, onReconnected, start, startInfo, stop, stopInfo, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### TXS_MON_LIST

    public static final String TXS_MON_LIST

See Also:
  Constant Field Values

#### TXS_MON_LIST_DESC

    public static final String TXS_MON_LIST_DESC

See Also:
  Constant Field Values

#### DFLT_MAX_COMPLETED_TX_CNT

    public static final int DFLT_MAX_COMPLETED_TX_CNT

Default maximum number of transactions that have completed.

See Also:
  Constant Field Values

#### DFLT_SLOW_TX_WARN_TIMEOUT

    public static final int DFLT_SLOW_TX_WARN_TIMEOUT

See Also:
  `IgniteSystemProperties.IGNITE_SLOW_TX_WARN_TIMEOUT`, Constant Field Values

#### DFLT_TX_DEADLOCK_DETECTION_MAX_ITERS

    public static final int DFLT_TX_DEADLOCK_DETECTION_MAX_ITERS

See Also:
  `IgniteSystemProperties.IGNITE_TX_DEADLOCK_DETECTION_MAX_ITERS`, Constant Field Values

#### DFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT

    public static final int DFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT

See Also:
  `IgniteSystemProperties.IGNITE_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT`, Constant Field Values

#### DFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_BUFFER_SIZE

    public static final int DFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_BUFFER_SIZE

See Also:
  `IgniteSystemProperties.IGNITE_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_BUFFER_SIZE`, Constant Field Values

#### DFLT_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT

    public static final int DFLT_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT

See Also:
  `IgniteSystemProperties.IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT`, Constant Field Values

#### COMPLETED_TX_STATES

    public static final Predicate<TxRecord> COMPLETED_TX_STATES

Returns `true` if transaction has completed states.

#### PREPARED_TX_STATES

    public static final Predicate<TxRecord> PREPARED_TX_STATES

Returns `true` if transaction has prepared states.

#### DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT

    public static final int DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT

One phase commit deferred ack request timeout.

#### DFLT_TX_OWNER_DUMP_REQUESTS_ALLOWED

    public static final boolean DFLT_TX_OWNER_DUMP_REQUESTS_ALLOWED

See Also:
  `IgniteSystemProperties.IGNITE_TX_OWNER_DUMP_REQUESTS_ALLOWED`, Constant Field Values

#### DFLT_DUMP_TX_COLLISIONS_INTERVAL

    public static final int DFLT_DUMP_TX_COLLISIONS_INTERVAL

See Also:
  `IgniteSystemProperties.IGNITE_DUMP_TX_COLLISIONS_INTERVAL`, Constant Field Values

### Constructor Detail

#### IgniteTxManager

    public IgniteTxManager()

### Method Detail

#### onKernalStop0

    protected void onKernalStop0(boolean cancel)

Overrides:
  `onKernalStop0` in class `GridCacheSharedManagerAdapter`
Parameters:
  `cancel` - Cancel flag.

#### start0

    protected void start0()
                   throws IgniteCheckedException

Overrides:
  `start0` in class `GridCacheSharedManagerAdapter`
Throws:
  `IgniteCheckedException` - If failed.

#### onKernalStart0

    protected void onKernalStart0(boolean active)

Overrides:
  `onKernalStart0` in class `GridCacheSharedManagerAdapter`
Parameters:
  `active` - Cluster active flag.

#### rollbackTransactionsForCache

    public void rollbackTransactionsForCache(int cacheId)

Parameters:
  `cacheId` - Cache ID.

#### rollbackTransactionsForStoppingCache

    public void rollbackTransactionsForStoppingCache(int cacheToStop)

Parameters:
  `cacheToStop` - Cache to stop.

#### rollbackOnTopologyChange

    public void rollbackOnTopologyChange(AffinityTopologyVersion topVer)

Rollback transactions blocking partition map exchange.

Parameters:
  `topVer` - Initial exchange version.

#### onDisconnected

    public void onDisconnected(IgniteFuture reconnectFut)

Specified by:
  `onDisconnected` in interface `GridCacheSharedManager`
Overrides:
  `onDisconnected` in class `GridCacheSharedManagerAdapter`
Parameters:
  `reconnectFut` - Reconnect future.

#### txHandler

    public IgniteTxHandler txHandler()

Returns:
  TX handler.

#### txOwnerDumpRequestsAllowed

    public boolean txOwnerDumpRequestsAllowed()

Sets if dump requests from local node to near node are allowed, when long running transaction is found. If allowed, the compute request to near node will be made to get thread dump of transaction owner thread.

Returns:
  `true` if allowed, `false` otherwise.

#### setTxOwnerDumpRequestsAllowed

    public void setTxOwnerDumpRequestsAllowed(boolean allowed)

Sets if dump requests from local node to near node are allowed, when long running transaction is found. If allowed, the compute request to near node will be made to get thread dump of transaction owner thread.

Parameters:
  `allowed` - whether allowed

#### longTransactionTimeDumpThreshold

    public long longTransactionTimeDumpThreshold()

Threshold timeout for long transactions, if transaction exceeds it, it will be dumped in log with information about how much time did it spent in system time (time while aquiring locks, preparing, commiting, etc) and user time (time when client node runs some code while holding transaction and not waiting it). Equals 0 if not set. No transactions are dumped in log if this parameter is not set.

Returns:
  Threshold timeout in milliseconds.

#### longTransactionTimeDumpThreshold

    public void longTransactionTimeDumpThreshold(long longTransactionTimeDumpThreshold)

Sets threshold timeout for long transactions, if transaction exceeds it, it will be dumped in log with information about how much time did it spent in system time (time while aquiring locks, preparing, commiting, etc) and user time (time when client node runs some code while holding transaction and not waiting it). Can be set to 0 - no transactions will be dumped in log in this case.

Parameters:
  `longTransactionTimeDumpThreshold` - Value of threshold timeout in milliseconds.

#### transactionTimeDumpSamplesCoefficient

    public double transactionTimeDumpSamplesCoefficient()

The coefficient for samples of completed transactions that will be dumped in log.

#### transactionTimeDumpSamplesCoefficient

    public void transactionTimeDumpSamplesCoefficient(double transactionTimeDumpSamplesCoefficient)

Sets the coefficient for samples of completed transactions that will be dumped in log.

#### transactionTimeDumpSamplesPerSecondLimit

    public int transactionTimeDumpSamplesPerSecondLimit()

The limit of samples of completed transactions that will be dumped in log per second, if `transactionTimeDumpSamplesCoefficient()` is above `0.0`. Must be integer value greater than `0`.

#### transactionTimeDumpSamplesPerSecondLimit

    public void transactionTimeDumpSamplesPerSecondLimit(int transactionTimeDumpSamplesPerSecondLimit)

Sets the limit of samples of completed transactions that will be dumped in log per second, if `transactionTimeDumpSamplesCoefficient()` is above `0.0`. Must be integer value greater than `0`.

#### salvageTx

    public void salvageTx(IgniteInternalTx tx)

Invalidates transaction.

Parameters:
  `tx` - Transaction.

#### printMemoryStats

    public void printMemoryStats()

Prints out memory stats to standard out.

USE ONLY FOR MEMORY PROFILING DURING TESTS.

Specified by:
  `printMemoryStats` in interface `GridCacheSharedManager`
Overrides:
  `printMemoryStats` in class `GridCacheSharedManagerAdapter`

#### threadMapSize

    public int threadMapSize()

Returns:
  Thread map size.

#### idMapSize

    public int idMapSize()

Returns:
  ID map size.

#### completedVersionsSize

    public int completedVersionsSize()

Returns:
  Committed versions size.

#### newTx

    public GridNearTxLocal newTx(boolean implicit,
                                 boolean implicitSingle,
                                 @Nullable
                                 @Nullable GridCacheContext sysCacheCtx,
                                 TransactionConcurrency concurrency,
                                 TransactionIsolation isolation,
                                 long timeout,
                                 boolean storeEnabled,
                                 Boolean mvccOp,
                                 int txSize,
                                 @Nullable
                                 @Nullable String lb,
                                 boolean tracingEnabled)

Parameters:
  `implicit` - `True` if transaction is implicit.
  `implicitSingle` - Implicit-with-single-key flag.
  `concurrency` - Concurrency.
  `isolation` - Isolation.
  `timeout` - transaction timeout.
  `mvccOp` - Whether this transaction is being started via SQL API or not, or `null` if unknown.
  `txSize` - Expected transaction size.
  `lb` - Label.
Returns:
  New transaction.

#### onCreated

    @Nullable
    public <T extends IgniteInternalTx> T onCreated(@Nullable
                                                              @Nullable GridCacheContext cacheCtx,
                                                              T tx)

Parameters:
  `cacheCtx` - Cache context.
  `tx` - Created transaction.
Returns:
  Started transaction.

#### finishLocalTxs

    public IgniteInternalFuture<Boolean> finishLocalTxs(AffinityTopologyVersion topVer)

Creates a future that will wait for all ongoing transactions that maybe affected by topology update to be finished. This set of transactions include

All `TransactionConcurrency.PESSIMISTIC` transactions with topology version less or equal to `topVer`.
`TransactionConcurrency.OPTIMISTIC` transactions in PREPARING state with topology version less or equal to `topVer` and having transaction key with entry that belongs to one of partitions in `parts`.

Parameters:
  `topVer` - Topology version.
Returns:
  Future that will be completed when all ongoing transactions are finished.

#### recoverLocalTxs

    public IgniteInternalFuture<Boolean> recoverLocalTxs(AffinityTopologyVersion topVer,
                                                         ClusterNode node)

Creates a future that will wait for all transactions with failed primary recovery.

Parameters:
  `topVer` - Topology version.
  `node` - Failed node.
Returns:
  Future that will be completed when all affected transactions are recovered.

#### finishAllTxs

    public IgniteInternalFuture<?> finishAllTxs(IgniteInternalFuture<?> finishLocalTxsFuture,
                                                AffinityTopologyVersion topVer)

Creates a future that will wait for finishing all tx updates on backups after all local transactions are finished. NOTE: As we send finish request to backup nodes after transaction successfully completed on primary node it's important to ensure that all updates from primary to backup are finished or at least remote transaction has created on backup node.

Parameters:
  `finishLocalTxsFuture` - Local transactions finish future.
  `topVer` - Topology version.
Returns:
  Future that will be completed when all ongoing transactions are finished.

#### needWaitTransaction

    public boolean needWaitTransaction(IgniteInternalTx tx,
                                       AffinityTopologyVersion topVer)

Parameters:
  `tx` - Transaction.
  `topVer` - Exchange version.
Returns:
  `True` if need wait transaction for exchange.

#### onStarted

    public boolean onStarted(IgniteInternalTx tx)

Transaction start callback (has to do with when any operation was performed on this transaction).

Parameters:
  `tx` - Started transaction.
Returns:
  `True` if transaction is not in completed set.

#### mappedVersion

    public GridCacheVersion mappedVersion(GridCacheVersion from)

Parameters:
  `from` - Near version.
Returns:
  DHT version for a near version.

#### addAlternateVersion

    public void addAlternateVersion(GridCacheVersion ver,
                                    IgniteInternalTx tx)

Parameters:
  `ver` - Alternate version.
  `tx` - Transaction.

#### localTx

    @Nullable
    public @Nullable IgniteTxLocalAdapter localTx()

Returns:
  Local transaction.

#### threadLocalTx

    public GridNearTxLocal threadLocalTx(GridCacheContext cctx)

Parameters:
  `cctx` - Cache context.
Returns:
  Transaction for current thread.

#### tx

    public IgniteInternalTx tx(IgniteInternalTx tx)

Sets transaction for current thread.

Returns:
  Previously associated transaction.

#### tx

    public <T> T tx()

Returns:
  Transaction for current thread.

#### lockedTopologyVersion

    @Nullable
    public @Nullable AffinityTopologyVersion lockedTopologyVersion(long threadId,
                                                                             IgniteInternalTx ignore)

Parameters:
  `threadId` - Thread ID.
  `ignore` - Transaction to ignore.
Returns:
  Not null topology version if current thread holds lock preventing topology change.

#### setTxTopologyHint

    public boolean setTxTopologyHint(@Nullable
                                     @Nullable AffinityTopologyVersion topVer)

Parameters:
  `topVer` - Locked topology version.
Returns:
  `True` if topology hint was set.

#### userTx

    @Nullable
    public @Nullable GridNearTxLocal userTx()

Returns:
  User transaction for current thread.

#### inUserTx

    public boolean inUserTx()

Returns:
  `True` if current thread is currently within transaction.

#### tx

    @Nullable
    public <T extends IgniteInternalTx> T tx(GridCacheVersion txId)

Parameters:
  `txId` - Transaction ID.
Returns:
  Transaction with given ID.

#### nearTx

    @Nullable
    public <T extends IgniteInternalTx> T nearTx(GridCacheVersion txId)

Parameters:
  `txId` - Transaction ID.
Returns:
  Transaction with given ID.

#### prepareTx

    public void prepareTx(IgniteInternalTx tx,
                          @Nullable
                          @Nullable Collection<IgniteTxEntry> entries)
                   throws IgniteCheckedException

Handles prepare stage.

Parameters:
  `tx` - Transaction to prepare.
  `entries` - Entries to lock or `null` if use default `IgniteInternalTx.optimisticLockEntries()`.
Throws:
  `IgniteCheckedException` - If preparation failed.

#### versions

    public IgnitePair<Collection<GridCacheVersion>> versions(GridCacheVersion min)

Parameters:
  `min` - Minimum version.
Returns:
  Pair [committed, rolledback] - never `null`, elements potentially empty, but also never `null`.

#### peekCompletedVersionsHistory

    public Boolean peekCompletedVersionsHistory(GridCacheVersion xid)

Peeks completed versions history map to find out whether transaction was committed or rolled back in the recent past.

Parameters:
  `xid` - Transaction XID version.
Returns:
  `true` if transaction was committed, `false` if transaction was rolled back, `null` if information is missed in history.

#### activeTransactions

    public Collection<IgniteInternalTx> activeTransactions()

Returns:
  Collection of active transactions.

#### removeCommittedTx

    public void removeCommittedTx(IgniteInternalTx tx)

Parameters:
  `tx` - Tx to remove.

#### addCommittedTx

    public void addCommittedTx(IgniteInternalTx tx)

Parameters:
  `tx` - Committed transaction.

#### addCommittedTxReturn

    public void addCommittedTxReturn(IgniteInternalTx tx,
                                     GridCacheReturnCompletableWrapper ret)

Parameters:
  `tx` - Committed transaction.

#### addRolledbackTx

    public boolean addRolledbackTx(IgniteInternalTx tx)

Parameters:
  `tx` - Committed transaction.
Returns:
  If transaction was not already present in completed set.

#### addCommittedTx

    public boolean addCommittedTx(IgniteInternalTx tx,
                                  GridCacheVersion xidVer,
                                  @Nullable
                                  @Nullable GridCacheVersion nearXidVer)

Parameters:
  `tx` - Tx.
  `xidVer` - Completed transaction version.
  `nearXidVer` - Optional near transaction ID.
Returns:
  If transaction was not already present in completed set.

#### addRolledbackTx

    public boolean addRolledbackTx(IgniteInternalTx tx,
                                   GridCacheVersion xidVer)

Parameters:
  `tx` - Tx.
  `xidVer` - Completed transaction version.
Returns:
  If transaction was not already present in completed set.

#### getCommittedTxReturn

    public GridCacheReturnCompletableWrapper getCommittedTxReturn(GridCacheVersion xidVer)

Parameters:
  `xidVer` - xidVer Completed transaction version.
Returns:
  Tx result.

#### removeTxReturn

    public void removeTxReturn(GridCacheVersion xidVer)

Parameters:
  `xidVer` - xidVer Completed transaction version.

#### commitTx

    public void commitTx(IgniteInternalTx tx)
                  throws IgniteCheckedException

Commits a transaction.

Parameters:
  `tx` - Transaction to commit.
Throws:
  `IgniteCheckedException` - If failed.

#### rollbackTx

    public void rollbackTx(IgniteInternalTx tx,
                           boolean clearThreadMap,
                           boolean skipCompletedVers)

Rolls back a transaction.

Parameters:
  `tx` - Transaction to rollback.
  `clearThreadMap` - `True` if need remove tx from thread map.
  `skipCompletedVers` - `True` if tx should skip adding itself to completed versions map on finish.

#### fastFinishTx

    public void fastFinishTx(GridNearTxLocal tx,
                             boolean commit,
                             boolean clearThreadMap)

Fast finish transaction. Can be used only if no locks were acquired.

Parameters:
  `tx` - Transaction to finish.
  `commit` - `True` if transaction is committed, `false` if rolled back.
  `clearThreadMap` - `True` if need remove tx from thread map.

#### forgetTx

    public void forgetTx(IgniteInternalTx tx)

Removes Tx from manager. Can be used only if there were no updates.

Parameters:
  `tx` - Transaction to finish.

#### clearThreadMap

    public void clearThreadMap(IgniteInternalTx tx)

Parameters:
  `tx` - Transaction to clear.

#### enterNearTxSystemSection

    public void enterNearTxSystemSection()

Enters system section for thread local near tx, if it is present. In this section system time for this transaction is counted.

#### leaveNearTxSystemSection

    public void leaveNearTxSystemSection()

Leaves system section for thread local near tx, if it is present.

#### onOwnerChanged

    public boolean onOwnerChanged(GridCacheEntryEx entry,
                                  GridCacheMvccCandidate owner)

Callback invoked whenever a member of a transaction acquires lock ownership.

Parameters:
  `entry` - Cache entry.
  `owner` - Candidate that won ownership.
Returns:
  `True` if transaction was notified, `false` otherwise.

#### txContext

    public void txContext(IgniteInternalTx tx)

Parameters:
  `tx` - Committing transaction.

#### txContextVersion

    @Nullable
    public @Nullable GridCacheVersion txContextVersion()

Gets version of transaction in tx context or `null` if tx context is empty.

This is a convenience method provided mostly for debugging.

Returns:
  Transaction version from transaction context.

#### resetContext

    public void resetContext()

Commit ended.

#### slowTxWarnTimeout

    public int slowTxWarnTimeout()

Returns:
  Slow tx warn timeout.

#### slowTxWarnTimeout

    public void slowTxWarnTimeout(int slowTxWarnTimeout)

Parameters:
  `slowTxWarnTimeout` - Slow tx warn timeout.

#### longOperationsDumpTimeout

    public long longOperationsDumpTimeout()

Returns:
  Long operations dump timeout.

#### longOperationsDumpTimeout

    public void longOperationsDumpTimeout(long longOpsDumpTimeout)

Parameters:
  `longOpsDumpTimeout` - Long operations dump timeout.

#### txsPreparedOrCommitted

    @Nullable
    public @Nullable IgniteInternalFuture<Boolean> txsPreparedOrCommitted(GridCacheVersion nearVer,
                                                                                    int txNum)

Checks if transactions with given near version ID was prepared or committed.

Parameters:
  `nearVer` - Near version ID.
  `txNum` - Number of transactions.
Returns:
  Future for flag indicating if transactions were prepared or committed or `null` for success future.

#### txCommitted

    public IgniteInternalFuture<Boolean> txCommitted(GridCacheVersion xidVer)

Parameters:
  `xidVer` - Version.
Returns:
  Future for flag indicating if transactions was committed.

#### remoteTxFinishFuture

    public IgniteInternalFuture<?> remoteTxFinishFuture(GridCacheVersion nearVer)

Parameters:
  `nearVer` - Near version.
Returns:
  Finish future for related remote transactions.

#### finishTxOnRecovery

    public void finishTxOnRecovery(IgniteInternalTx tx,
                                   boolean commit)

Commits or rolls back prepared transaction.

Parameters:
  `tx` - Transaction.
  `commit` - Whether transaction should be committed or rolled back.

#### commitIfPrepared

    public IgniteInternalFuture<Boolean> commitIfPrepared(IgniteInternalTx tx,
                                                          Set<UUID> failedNodeIds)

Commits transaction in case when node started transaction failed, but all related transactions were prepared (invalidates transaction if it is not fully prepared).

Parameters:
  `tx` - Transaction.
  `failedNodeIds` - Failed nodes IDs.

#### deadlockDetectionEnabled

    public boolean deadlockDetectionEnabled()

Returns:
  `True` if deadlock detection is enabled.

#### detectDeadlock

    public IgniteInternalFuture<TxDeadlock> detectDeadlock(IgniteInternalTx tx,
                                                           Set<IgniteTxKey> keys)

Performs deadlock detection for given keys.

Parameters:
  `tx` - Target tx.
  `keys` - Keys.
Returns:
  Detection result.

#### addFuture

    public void addFuture(org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.TxDeadlockFuture fut)

Parameters:
  `fut` - Future.

#### future

    @Nullable
    public @Nullable org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.TxDeadlockFuture future(long futId)

Parameters:
  `futId` - Future ID.
Returns:
  Found future.

#### removeFuture

    public void removeFuture(long futId)

Parameters:
  `futId` - Future ID.

#### sendDeferredAckResponse

    public void sendDeferredAckResponse(UUID nodeId,
                                        GridCacheVersion ver)

Parameters:
  `nodeId` - Node ID to send message to.
  `ver` - Version to ack.

#### deadlockDetectionFutures

    public Collection<IgniteInternalFuture<?>> deadlockDetectionFutures()

Returns:
  Collection of active transaction deadlock detection futures.

#### suspendTx

    public void suspendTx(GridNearTxLocal tx)
                   throws IgniteCheckedException

Suspends transaction. Should not be used directly. Use tx.suspend() instead.

Parameters:
  `tx` - Transaction to be suspended.
Throws:
  `IgniteCheckedException` - If failed to suspend transaction.
See Also:
  `resumeTx(GridNearTxLocal, long)`, `GridNearTxLocal.suspend()`, `GridNearTxLocal.resume()`

#### resumeTx

    public void resumeTx(GridNearTxLocal tx,
                         long threadId)
                  throws IgniteCheckedException

Resume transaction in current thread. Please don't use directly. Use tx.resume() instead.

Parameters:
  `tx` - Transaction to be resumed.
  `threadId` - Thread id to restore.
Throws:
  `IgniteCheckedException` - If failed to resume tx.
See Also:
  `suspendTx(GridNearTxLocal)`, `GridNearTxLocal.suspend()`, `GridNearTxLocal.resume()`

#### setMvccState

    public void setMvccState(IgniteInternalTx tx,
                             TransactionState state)

Sets MVCC state.

Parameters:
  `tx` - Transaction.
  `state` - New state.

#### mvccFinish

    public void mvccFinish(IgniteTxAdapter tx)

Finishes MVCC transaction.

Parameters:
  `tx` - Transaction.

#### setTxTimeoutOnPartitionMapExchange

    public void setTxTimeoutOnPartitionMapExchange(long timeout)
                                            throws IgniteCheckedException

Sets transaction timeout on partition map exchange.

Parameters:
  `timeout` - Transaction timeout on partition map exchange in milliseconds.
Throws:
  `IgniteCheckedException`

#### onTxTimeoutOnPartitionMapExchangeChange

    public void onTxTimeoutOnPartitionMapExchangeChange(TxTimeoutOnPartitionMapExchangeChangeMessage msg)

Callback invoked from discovery thread when discovery custom message is received.

Parameters:
  `msg` - Discovery message for changing transaction timeout on partition map exchange.

#### processTxTimeoutOnPartitionMapExchangeChange

    public void processTxTimeoutOnPartitionMapExchangeChange(TxTimeoutOnPartitionMapExchangeChangeMessage msg)

The task for changing transaction timeout on partition map exchange processed by exchange worker.

Parameters:
  `msg` - Message.

#### checkEmptyTransactions

    public void checkEmptyTransactions(@NotNull
                                       @NotNull IgniteOutClosure<String> errMsgConstructor)

Method checks that current thread does not have active transactions. If transaction or topology lock is hold by current thread exception `IgniteException` with given `errMsgConstructor` message will be thrown.

Parameters:
  `errMsgConstructor` - Error message constructor.

#### setTxOwnerDumpRequestsAllowedDistributed

    public void setTxOwnerDumpRequestsAllowedDistributed(boolean allowed)

Sets if dump requests from local node to near node are allowed, when long running transaction is found. If allowed, the compute request to near node will be made to get thread dump of transaction owner thread. Also broadcasts this setting on other server nodes in cluster.

Parameters:
  `allowed` - whether allowed

#### longTransactionTimeDumpThresholdDistributed

    public void longTransactionTimeDumpThresholdDistributed(long threshold)

Sets threshold timeout in milliseconds for long transactions, if transaction exceeds it, it will be dumped in log with information about how much time did it spent in system time (time while aquiring locks, preparing, commiting, etc.) and user time (time when client node runs some code while holding transaction). Can be set to 0 - no transactions will be dumped in log in this case.

Parameters:
  `threshold` - Threshold timeout in milliseconds.

#### transactionTimeDumpSamplesCoefficientDistributed

    public void transactionTimeDumpSamplesCoefficientDistributed(double coefficient)

Sets the coefficient for samples of long running transactions that will be dumped in log, if `longTransactionTimeDumpThreshold()` is set to non-zero value."

Parameters:
  `coefficient` - Coefficient, must be value between 0.0 and 1.0 inclusively.

#### longTransactionTimeDumpSamplesPerSecondLimit

    public void longTransactionTimeDumpSamplesPerSecondLimit(int limit)

Sets the limit of samples of completed transactions that will be dumped in log per second, if `transactionTimeDumpSamplesCoefficient()` is above `0.0`. Must be integer value greater than `0`.

Parameters:
  `limit` - Limit value.

#### stop0

    protected void stop0(boolean cancel)

Overrides:
  `stop0` in class `GridCacheSharedManagerAdapter`
Parameters:
  `cancel` - Cancel flag.

#### longOperationsDumpTimeoutDistributed

    public void longOperationsDumpTimeoutDistributed(long longOpsDumpTimeout)

Setting (for all nodes) a timeout (in millis) for printing long-running transactions as well as transactions that cannot receive locks for all their keys for a long time. Set less than or equal `0` to disable.

Parameters:
  `longOpsDumpTimeout` - Long operations dump timeout.

#### collisionsDumpInterval

    public int collisionsDumpInterval()

Returns tx keys collisions dump interval, for additional info check `IgniteSystemProperties.IGNITE_DUMP_TX_COLLISIONS_INTERVAL` description.

Returns:
  Collisions dump interval.

#### collisionsDumpIntervalDistributed

    public void collisionsDumpIntervalDistributed(int collisionsDumpInterval)

Changes tx key collisions dump interval. For additional info check `IgniteSystemProperties.IGNITE_DUMP_TX_COLLISIONS_INTERVAL` description.

Parameters:
  `collisionsDumpInterval` - New collisions dump interval or negative for disabling.

#### pushCollidingKeysWithQueueSize

    public void pushCollidingKeysWithQueueSize(GridCacheMapEntry key,
                                               int queueSize)

Collect queue size per key collisions info.

Parameters:
  `key` - Key.
  `queueSize` - Collisions queue size

#### detectPossibleCollidingKeys

    public void detectPossibleCollidingKeys(GridDistributedCacheEntry entry)

Check local and remote candidates queue size.

Parameters:
  `entry` - CacheEntry.

#### getDistributedTransactionConfiguration

    public DistributedTransactionConfiguration getDistributedTransactionConfiguration()

Returns:
  Distributed configuration.

#### collectTxStates

    public void collectTxStates(TxRecord txRec)

Collects tx states `TransactionState` for further correct restoring.

Parameters:
  `txRec` - tx Record.

#### uncommitedTx

    public boolean uncommitedTx(DataEntry dataEntry)

Parameters:
  `dataEntry` - Processing entry.
Returns:
  `true` If entry contains not completed tx version.

#### clearUncommitedStates

    public void clearUncommitedStates()

Clears tx states collections.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022