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 Modifier and Type Class Description classIgniteTxManager.TxDumpsThrottlingThis class is used to store information about transaction time dump throttling.
-
Field Summary
Fields Modifier and Type Field Description static Predicate<TxRecord>COMPLETED_TX_STATESReturnstrueif transaction has completed states.static intDEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUTOne phase commit deferred ack request timeout.static intDFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_BUFFER_SIZEstatic intDFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUTstatic intDFLT_DUMP_TX_COLLISIONS_INTERVALstatic intDFLT_MAX_COMPLETED_TX_CNTDefault maximum number of transactions that have completed.static intDFLT_SLOW_TX_WARN_TIMEOUTstatic intDFLT_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMITstatic intDFLT_TX_DEADLOCK_DETECTION_MAX_ITERSstatic booleanDFLT_TX_OWNER_DUMP_REQUESTS_ALLOWEDstatic Predicate<TxRecord>PREPARED_TX_STATESReturnstrueif transaction has prepared states.static StringTXS_MON_LISTstatic StringTXS_MON_LIST_DESC-
Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter
cctx, diagnosticLog, log
-
-
Constructor Summary
Constructors Constructor Description IgniteTxManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<IgniteInternalTx>activeTransactions()voidaddAlternateVersion(GridCacheVersion ver, IgniteInternalTx tx)voidaddCommittedTx(IgniteInternalTx tx)booleanaddCommittedTx(IgniteInternalTx tx, GridCacheVersion xidVer, @Nullable GridCacheVersion nearXidVer)voidaddCommittedTxReturn(IgniteInternalTx tx, GridCacheReturnCompletableWrapper ret)voidaddFuture(org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.TxDeadlockFuture fut)booleanaddRolledbackTx(IgniteInternalTx tx)booleanaddRolledbackTx(IgniteInternalTx tx, GridCacheVersion xidVer)voidcheckEmptyTransactions(@NotNull IgniteOutClosure<String> errMsgConstructor)Method checks that current thread does not have active transactions.voidclearThreadMap(IgniteInternalTx tx)voidclearUncommitedStates()Clears tx states collections.voidcollectTxStates(TxRecord txRec)Collects tx statesTransactionStatefor further correct restoring.intcollisionsDumpInterval()Returns tx keys collisions dump interval, for additional info checkIgniteSystemProperties.IGNITE_DUMP_TX_COLLISIONS_INTERVALdescription.voidcollisionsDumpIntervalDistributed(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).voidcommitTx(IgniteInternalTx tx)Commits a transaction.intcompletedVersionsSize()booleandeadlockDetectionEnabled()Collection<IgniteInternalFuture<?>>deadlockDetectionFutures()IgniteInternalFuture<TxDeadlock>detectDeadlock(IgniteInternalTx tx, Set<IgniteTxKey> keys)Performs deadlock detection for given keys.voiddetectPossibleCollidingKeys(GridDistributedCacheEntry entry)Check local and remote candidates queue size.static voidensureTransactionModeSupported(TransactionIsolation isolation)Checks if transaction mode supported for transaction aware queries.voidenterNearTxSystemSection()Enters system section for thread local near tx, if it is present.voidfastFinishTx(GridNearTxLocal tx, boolean commit, boolean clearThreadMap)Fast finish transaction.IgniteInternalFuture<?>finishAllTxs(IgniteInternalFuture<?> finishLocTxsFut, 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.voidfinishTxOnRecovery(IgniteInternalTx tx, boolean commit)Commits or rolls back prepared transaction.@Nullable org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.TxDeadlockFuturefuture(long futId)GridCacheReturnCompletableWrappergetCommittedTxReturn(GridCacheVersion xidVer)intidMapSize()booleaninUserTx()voidleaveNearTxSystemSection()Leaves system section for thread local near tx, if it is present.@Nullable IgniteTxLocalAdapterlocalTx()@Nullable AffinityTopologyVersionlockedTopologyVersion(long threadId, IgniteInternalTx ignore)longlongOperationsDumpTimeout()voidlongOperationsDumpTimeout(long longOpsDumpTimeout)voidlongOperationsDumpTimeoutDistributed(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.voidlongTransactionTimeDumpSamplesPerSecondLimit(int limit)Sets the limit of samples of completed transactions that will be dumped in log per second, iftransactionTimeDumpSamplesCoefficient()is above0.0.longlongTransactionTimeDumpThreshold()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).voidlongTransactionTimeDumpThresholdDistributed(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.)GridCacheVersionmappedVersion(GridCacheVersion from)<T extends IgniteInternalTx>
TnearTx(GridCacheVersion txId)booleanneedWaitTransaction(IgniteInternalTx tx, AffinityTopologyVersion topVer)GridNearTxLocalnewTx(boolean implicit, boolean implicitSingle, @Nullable GridCacheContext sysCacheCtx, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, boolean storeEnabled, int txSize, @Nullable String lb)voidonCommitCallback(Consumer<IgniteInternalTx> callback)<T extends IgniteInternalTx>
TonCreated(@Nullable GridCacheContext cacheCtx, T tx)voidonDisconnected(IgniteFuture reconnectFut)protected voidonKernalStop0(boolean cancel)booleanonOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner)Callback invoked whenever a member of a transaction acquires lock ownership.booleanonStarted(IgniteInternalTx tx)Transaction start callback (has to do with when any operation was performed on this transaction).voidonTxTimeoutOnPartitionMapExchangeChange(TxTimeoutOnPartitionMapExchangeChangeMessage msg)Callback invoked from discovery thread when discovery custom message is received.BooleanpeekCompletedVersionsHistory(GridCacheVersion xid)Peeks completed versions history map to find out whether transaction was committed or rolled back in the recent past.voidprepareTx(IgniteInternalTx tx, @Nullable Collection<IgniteTxEntry> entries)Handles prepare stage.voidprintMemoryStats()Prints out memory stats to standard out.voidprocessTxTimeoutOnPartitionMapExchangeChange(TxTimeoutOnPartitionMapExchangeChangeMessage msg)The task for changing transaction timeout on partition map exchange processed by exchange worker.voidpushCollidingKeysWithQueueSize(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)voidremoveCommittedTx(IgniteInternalTx tx)voidremoveFuture(long futId)voidremoveTxReturn(GridCacheVersion xidVer)voidresetContext()Commit ended.voidresumeTx(GridNearTxLocal tx, long threadId)Resume transaction in current thread.voidrollbackOnTopologyChange(AffinityTopologyVersion topVer)Rollback transactions blocking partition map exchange.voidrollbackTransactionsForCache(int cacheId)voidrollbackTransactionsForStoppingCache(int cacheToStop)voidrollbackTx(IgniteInternalTx tx, boolean clearThreadMap, boolean skipCompletedVers)Rolls back a transaction.voidsalvageTx(IgniteInternalTx tx)Invalidates transaction.voidsendDeferredAckResponse(UUID nodeId, GridCacheVersion ver)voidsendTransactionMessage(UUID nodeId, GridCacheMessage msg, IgniteInternalTx tx, byte plc)Sends transaction message after transforming it.voidsendTransactionMessage(ClusterNode n, GridCacheMessage msg, IgniteInternalTx tx, byte plc)Sends transaction message after transforming it.voidsetTxOwnerDumpRequestsAllowedDistributed(boolean allowed)Sets if dump requests from local node to near node are allowed, when long-running transaction is found.voidsetTxTimeoutOnPartitionMapExchange(long timeout)Sets transaction timeout on partition map exchange.booleansetTxTopologyHint(@Nullable AffinityTopologyVersion topVer)voidslowTxWarnTimeout(int slowTxWarnTimeout)protected voidstart0()protected voidstop0(boolean cancel)voidsuspendTx(GridNearTxLocal tx)Suspends transaction.GridNearTxLocalthreadLocalTx(GridCacheContext cctx)intthreadMapSize()doubletransactionTimeDumpSamplesCoefficient()The coefficient for samples of completed transactions that will be dumped in log.voidtransactionTimeDumpSamplesCoefficientDistributed(double coefficient)Sets the coefficient for samples of long-running transactions that will be dumped in log, iflongTransactionTimeDumpThreshold()is set to non-zero value.inttransactionTimeDumpSamplesPerSecondLimit()The limit of samples of completed transactions that will be dumped in log per second, iftransactionTimeDumpSamplesCoefficient()is above0.0.<T extends IgniteInternalTx>
Ttx()IgniteInternalTxtx(IgniteInternalTx tx)Sets transaction for current thread.<T extends IgniteInternalTx>
Ttx(GridCacheVersion txId)IgniteInternalFuture<Boolean>txCommitted(GridCacheVersion xidVer)voidtxContext(IgniteInternalTx tx)IgniteTxHandlertxHandler()voidtxMessageTransformer(BiFunction<GridCacheMessage,IgniteInternalTx,GridCacheMessage> transform)booleantxOwnerDumpRequestsAllowed()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.booleanuncommitedTx(DataEntry dataEntry)@Nullable GridNearTxLocaluserTx()IgnitePair<Collection<GridCacheVersion>>versions(GridCacheVersion min)-
Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter
context, isStopping, kernalStartInfo, kernalStopInfo, onKernalStart, onKernalStart0, onKernalStop, onReconnected, start, startInfo, stop, stopInfo, toString
-
-
-
-
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
-
DFLT_TX_DEADLOCK_DETECTION_MAX_ITERS
public static final int DFLT_TX_DEADLOCK_DETECTION_MAX_ITERS
-
DFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT
public static final int DFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT
-
DFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_BUFFER_SIZE
public static final int DFLT_DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_BUFFER_SIZE
-
DFLT_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT
public static final int DFLT_TRANSACTION_TIME_DUMP_SAMPLES_PER_SECOND_LIMIT
-
COMPLETED_TX_STATES
public static final Predicate<TxRecord> COMPLETED_TX_STATES
Returnstrueif transaction has completed states.
-
PREPARED_TX_STATES
public static final Predicate<TxRecord> PREPARED_TX_STATES
Returnstrueif 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
-
DFLT_DUMP_TX_COLLISIONS_INTERVAL
public static final int DFLT_DUMP_TX_COLLISIONS_INTERVAL
-
-
Method Detail
-
onKernalStop0
protected void onKernalStop0(boolean cancel)
- Overrides:
onKernalStop0in classGridCacheSharedManagerAdapter- Parameters:
cancel- Cancel flag.
-
start0
protected void start0()
- Overrides:
start0in classGridCacheSharedManagerAdapter
-
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:
onDisconnectedin interfaceGridCacheSharedManager- Overrides:
onDisconnectedin classGridCacheSharedManagerAdapter- 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:
trueif allowed,falseotherwise.
-
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.
-
transactionTimeDumpSamplesCoefficient
public double transactionTimeDumpSamplesCoefficient()
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, iftransactionTimeDumpSamplesCoefficient()is above0.0. Must be integer value greater than0.
-
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:
printMemoryStatsin interfaceGridCacheSharedManager- Overrides:
printMemoryStatsin classGridCacheSharedManagerAdapter
-
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, int txSize, @Nullable @Nullable String lb)
- Parameters:
implicit-Trueif transaction is implicit.implicitSingle- Implicit-with-single-key flag.concurrency- Concurrency.isolation- Isolation.timeout- transaction timeout.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.PESSIMISTICtransactions with topology version less or equal totopVer.TransactionConcurrency.OPTIMISTICtransactions in PREPARING state with topology version less or equal totopVerand having transaction key with entry that belongs to one of partitions inparts.- 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<?> finishLocTxsFut, 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:
finishLocTxsFut- 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:
Trueif 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:
Trueif 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 extends IgniteInternalTx> 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:
Trueif topology hint was set.
-
userTx
@Nullable public @Nullable GridNearTxLocal userTx()
- Returns:
- User transaction for current thread.
-
inUserTx
public boolean inUserTx()
- Returns:
Trueif 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 ornullif use defaultIgniteInternalTx.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 nevernull.
-
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:
trueif transaction was committed,falseif transaction was rolled back,nullif 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-Trueif need remove tx from thread map.skipCompletedVers-Trueif 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-Trueif transaction is committed,falseif rolled back.clearThreadMap-Trueif need remove tx from thread map.
-
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:
Trueif transaction was notified,falseotherwise.
-
txContext
public void txContext(IgniteInternalTx tx)
- Parameters:
tx- Committing transaction.
-
resetContext
public void resetContext()
Commit ended.
-
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
nullfor 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:
Trueif 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()
-
setTxTimeoutOnPartitionMapExchange
public void setTxTimeoutOnPartitionMapExchange(long timeout) throws IgniteCheckedExceptionSets 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 exceptionIgniteExceptionwith givenerrMsgConstructormessage 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, iflongTransactionTimeDumpThreshold()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, iftransactionTimeDumpSamplesCoefficient()is above0.0. Must be integer value greater than0.- Parameters:
limit- Limit value.
-
stop0
protected void stop0(boolean cancel)
- Overrides:
stop0in classGridCacheSharedManagerAdapter- 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 equal0to disable.- Parameters:
longOpsDumpTimeout- Long operations dump timeout.
-
collisionsDumpInterval
public int collisionsDumpInterval()
Returns tx keys collisions dump interval, for additional info checkIgniteSystemProperties.IGNITE_DUMP_TX_COLLISIONS_INTERVALdescription.- Returns:
- Collisions dump interval.
-
collisionsDumpIntervalDistributed
public void collisionsDumpIntervalDistributed(int collisionsDumpInterval)
Changes tx key collisions dump interval. For additional info checkIgniteSystemProperties.IGNITE_DUMP_TX_COLLISIONS_INTERVALdescription.- 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.
-
txMessageTransformer
public void txMessageTransformer(BiFunction<GridCacheMessage,IgniteInternalTx,GridCacheMessage> transform)
- Parameters:
transform- Transaction message transformer.
-
onCommitCallback
public void onCommitCallback(Consumer<IgniteInternalTx> callback)
- Parameters:
callback- Callback invoked on transaction commit.
-
sendTransactionMessage
public void sendTransactionMessage(UUID nodeId, GridCacheMessage msg, IgniteInternalTx tx, byte plc) throws IgniteCheckedException
Sends transaction message after transforming it.- Parameters:
nodeId- Node ID to send message.msg- Original message to transform.tx- Transaction.plc- IO policy.- Throws:
IgniteCheckedException
-
sendTransactionMessage
public void sendTransactionMessage(ClusterNode n, GridCacheMessage msg, IgniteInternalTx tx, byte plc) throws IgniteCheckedException
Sends transaction message after transforming it.- Parameters:
n- Node to send message.msg- Original message to transform.tx- Transaction.plc- IO policy.- Throws:
IgniteCheckedException
-
collectTxStates
public void collectTxStates(TxRecord txRec)
Collects tx statesTransactionStatefor further correct restoring.- Parameters:
txRec- tx Record.
-
uncommitedTx
public boolean uncommitedTx(DataEntry dataEntry)
- Parameters:
dataEntry- Processing entry.- Returns:
trueIf entry contains not completed tx version.
-
clearUncommitedStates
public void clearUncommitedStates()
Clears tx states collections.
-
ensureTransactionModeSupported
public static void ensureTransactionModeSupported(TransactionIsolation isolation)
Checks if transaction mode supported for transaction aware queries.- Parameters:
isolation- Transaction isolation to check.
-
-