public static boolean remoteMessageUsesTXProxy() { final TXManagerImpl.TXContext context; return ((context = TXManagerImpl.currentTXContext()) != null && context.msgUsesTXProxy); }
public static void waitForPendingCommitForTest() { final TXContext context = currentTXContext(); if (context != null) { context.waitForPendingCommit(); } }
public final boolean batchingEnabled() { final TXManagerImpl.TXContext context; return !isSnapshot() && (this.enableBatching || ((context = TXManagerImpl.currentTXContext()) != null && context.forceBatching)); }
public static void releaseThreadsSockets() { // clear TXContext from global list TXManagerImpl.TXContext context = TXManagerImpl.currentTXContext(); if (context != null) { context.threadClose(); } ConnectionTable ct = lastInstance.get(); if (ct == null) { return; } ct.removeAndCloseThreadOwnedSockets(); // lastInstance = null; }
/** * If the current thread is in a transaction then suspend will cause it to no * longer be in a transaction. * * @return the state of the transaction or null. Pass this value to * {@link TXManagerImpl#resume} to reactivate the suspended * transaction. */ public final TXStateInterface internalSuspend() { final TXContext context = currentTXContext(); TXStateInterface tx = null; if (context != null && (tx = context.getTXState()) != null) { context.clearTXState(); } return tx; }
protected final void flushTXPendingOps() { final TXStateInterface tx = this.txState; if (tx != null) { // flush all batched TXStateProxy ops before sending lastResult tx.flushPendingOps(this.dm); } else { // check if there was a TX started within function body then wait for // commit before returning final TXManagerImpl.TXContext txContext = TXManagerImpl .currentTXContext(); if (txContext != null) { txContext.waitForPendingCommit(); } } } }
protected final void flushTXPendingOps() { final TXStateInterface tx = this.txState; if (tx != null) { // flush all batched TXStateProxy ops before sending lastResult tx.flushPendingOps(this.dm); } else { // check if there was a TX started within function body then wait for // commit before returning final TXManagerImpl.TXContext txContext = TXManagerImpl .currentTXContext(); if (txContext != null) { txContext.waitForPendingCommit(); } } } }
protected final void flushTXPendingOps() { final TXStateInterface tx = this.txState; if (tx != null) { // flush all batched TXStateProxy ops before sending lastResult tx.flushPendingOps(this.dm); } else { // check if there was a TX started within function body then wait for // commit before returning final TXManagerImpl.TXContext txContext = TXManagerImpl .currentTXContext(); if (txContext != null) { txContext.waitForPendingCommit(); } } } }
public TXId suspend() { final TXContext context = currentTXContext(); TXStateInterface tx = null; if (context != null && (tx = context.getTXState()) != null) { final TXId txId = tx.getTransactionId(); context.clearTXState(); this.suspendedTXs.put(txId, tx); // wake up waiting threads Queue<Thread> waitingThreads = this.waitMap.get(txId); if (waitingThreads != null) { Thread waitingThread = null; while (true) { waitingThread = waitingThreads.poll(); if (waitingThread == null || !Thread.currentThread().equals(waitingThread)) { break; } } if (waitingThread != null) { LockSupport.unpark(waitingThread); } } scheduleExpiry(txId); return txId; } return null; }
public AbstractOperationMessage(final TXStateInterface tx) { if (tx != null) { initTXState(tx); } // check for a previous TX pending commit, if any if (sendPendingTXId()) { initPendingTXId(TXManagerImpl.currentTXContext(), tx); } }
@Override public void xa_commit(boolean onePhase) throws StandardException { //boolean successInSecondPhase = false; final TXStateInterface tx = getTopTXState(); if (tx == null || !tx.isCoordinator()) { return; } try { if (onePhase) { commit(COMMIT_SYNC, tx, TXManagerImpl.FULL_COMMIT, null); // this.txState.commit(null); } else { // wait for second-phase commit to also complete for 2-phase commit final TXManagerImpl.TXContext context = TXManagerImpl .currentTXContext(); if (context != null) { context.setWaitForPhase2Commit(); } commit(COMMIT_SYNC, tx, TXManagerImpl.PHASE_TWO_COMMIT, this.txContextFromPrepareStage); //this.txState.commitPhase2(this.txContextFromPrepareStage, null); //successInSecondPhase = true; } } finally { this.prepared = false; this.txContextFromPrepareStage = null; } }
@Override public void xa_commit(boolean onePhase) throws StandardException { //boolean successInSecondPhase = false; final TXStateInterface tx = getTopTXState(); if (tx == null || !tx.isCoordinator()) { return; } try { if (onePhase) { commit(COMMIT_SYNC, tx, TXManagerImpl.FULL_COMMIT, null); // this.txState.commit(null); } else { // wait for second-phase commit to also complete for 2-phase commit final TXManagerImpl.TXContext context = TXManagerImpl .currentTXContext(); if (context != null) { context.setWaitForPhase2Commit(); } commit(COMMIT_SYNC, tx, TXManagerImpl.PHASE_TWO_COMMIT, this.txContextFromPrepareStage); //this.txState.commitPhase2(this.txContextFromPrepareStage, null); //successInSecondPhase = true; } } finally { this.prepared = false; this.txContextFromPrepareStage = null; } }
@Override public void xa_commit(boolean onePhase) throws StandardException { //boolean successInSecondPhase = false; final TXStateInterface tx = getTopTXState(); if (tx == null || !tx.isCoordinator()) { return; } try { if (onePhase) { commit(COMMIT_SYNC, tx, TXManagerImpl.FULL_COMMIT, null); // this.txState.commit(null); } else { // wait for second-phase commit to also complete for 2-phase commit final TXManagerImpl.TXContext context = TXManagerImpl .currentTXContext(); if (context != null) { context.setWaitForPhase2Commit(); } commit(COMMIT_SYNC, tx, TXManagerImpl.PHASE_TWO_COMMIT, this.txContextFromPrepareStage); //this.txState.commitPhase2(this.txContextFromPrepareStage, null); //successInSecondPhase = true; } } finally { this.prepared = false; this.txContextFromPrepareStage = null; } }
private static void executeOnLeadNode(SnappySelectResultSet rs, GfxdResultCollector<Object> rc, String sql, boolean enableStreaming, long connId, String schema, ParameterValueSet pvs, boolean isPreparedStatement, boolean isUpdateOrDelete, LanguageConnectionContext lcc) throws StandardException { // TODO: KN probably username, statement id and connId to be sent in // execution and of course tx id when transaction will be supported. LeadNodeExecutionContext ctx = new LeadNodeExecutionContext(connId); LeadNodeExecutorMsg msg = new LeadNodeExecutorMsg(sql, schema, ctx, rc, pvs, isPreparedStatement, false, isUpdateOrDelete); // release all locks before sending the message else it can lead to deadlocks if (lcc != null) { lcc.getTransactionExecute().releaseAllLocks(true, true); } // wait for any pending transactions before routing new operations to lead final TXManagerImpl.TXContext txContext = TXManagerImpl .currentTXContext(); if (txContext != null) { txContext.waitForPendingCommit(); } try { msg.executeFunction(enableStreaming, false, rs, true); } catch (RuntimeException | SQLException ex) { Exception e = LeadNodeExecutorMsg.handleLeadNodeException(ex, sql); throw Misc.processFunctionException( "SnappyActivation::executeOnLeadNode", e, null, null); } }
.currentTXContext(); if (txContext != null) { txContext.waitForPendingCommit();
.currentTXContext(); if (txContext != null) { txContext.waitForPendingCommit();
.currentTXContext(); if (txContext != null) { txContext.waitForPendingCommit();
/** * Roll back the transaction associated with the current thread. When this * method completes, the thread is no longer associated with a transaction. */ public final void rollback(final TXStateInterface tx, Object callbackArg, final boolean isRemoteRollback) { checkClosed(); if (tx == null) { throw new IllegalTransactionStateException(LocalizedStrings .TXManagerImpl_THREAD_DOES_NOT_HAVE_AN_ACTIVE_TRANSACTION .toLocalizedString()); } if (tx.isJTA()) { throw new IllegalTransactionStateException(LocalizedStrings .TXManagerImpl_CAN_NOT_ROLLBACK_THIS_TRANSACTION_IS_ENLISTED_WITH_A_JTA_TRANSACTION_USE_THE_JTA_MANAGER_TO_PERFORM_THE_ROLLBACK .toLocalizedString()); } final long opStart = CachePerfStats.getStatTime(); final long lifeTime = opStart - tx.getBeginTime(); TXManagerImpl.TXContext context = TXManagerImpl.currentTXContext(); if (context != null) { context.clearTXStateAll(); } tx.rollback(callbackArg); noteRollbackSuccess(opStart, lifeTime, tx, isRemoteRollback); }
this.txManager.clearTXState(); TXManagerImpl.TXContext context = TXManagerImpl.currentTXContext(); if (context != null) {
public static String GET_SNAPSHOT_TXID(Boolean delayRollover) throws SQLException, StandardException { LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC(); GemFireTransaction tc = (GemFireTransaction)lcc.getTransactionExecute(); TXManagerImpl.TXContext context = TXManagerImpl.currentTXContext(); TXStateInterface tx = context != null ? context.getSnapshotTXState() : null; if (GemFireXDUtils.TraceExecution) { SanityManager.DEBUG_PRINT(GfxdConstants.TRACE_EXECUTION, "in function GET_SNAPSHOT_TXID() for conn " + tc.getConnectionID() + " delayRollover=" + delayRollover + " tc id" + tc.getTransactionIdString() + " TxManager " + TXManagerImpl.getCurrentTXId() + " snapshot tx : " + tx); } String txId; if (tx != null && !tx.isClosed()) { tx.getProxy().setColumnRolloverDisabled(delayRollover); txId = tx.getTransactionId().stringFormat(); } else { txId = ""; } // tc commit will clear all the artifacts but will not commit actual txState // that should be committed in COMMIT procedure tc.clearActiveTXState(true, true); //tc.resetActiveTXState(true); if (context != null) { context.setSnapshotTXState(null); } return txId; }