Search in sources :

Example 1 with HeuristicRollback

use of org.omg.CosTransactions.HeuristicRollback in project narayana by jbosstm.

the class ServerTopLevelAction method commit.

public void commit() throws NotPrepared, HeuristicRollback, HeuristicMixed, HeuristicHazard, SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ServerTopLevelAction::commit for " + _theUid);
    }
    if (_theControl == null) {
        throw new INVALID_TRANSACTION(ExceptionCodes.SERVERAA_NO_CONTROL, CompletionStatus.COMPLETED_NO);
    }
    if (_theControl.isWrapper()) {
        destroyResource();
        return;
    }
    ServerTransaction theTransaction = (ServerTransaction) _theControl.getImplHandle();
    // LockManager needs to know if there is a transaction
    ThreadActionData.pushAction(theTransaction);
    int actionStatus = theTransaction.status();
    boolean notPrepared = false;
    if (actionStatus == ActionStatus.PREPARED) {
        /*
	     * This will also call any after_completions on
	     * registered synchronizations.
	     */
        actionStatus = theTransaction.doPhase2Commit();
    } else {
        if (actionStatus == ActionStatus.RUNNING) {
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ServerTopLevelAction::commit for " + _theUid + " : NotPrepared");
            }
            notPrepared = true;
        }
    }
    ThreadActionData.popAction();
    if (notPrepared)
        throw new NotPrepared();
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ServerTopLevelAction::commit for " + _theUid + " : " + ActionStatus.stringForm(actionStatus));
    }
    switch(actionStatus) {
        case ActionStatus.PREPARED:
            throw new INVALID_TRANSACTION(ExceptionCodes.SERVERAA_NO_CONTROL, CompletionStatus.COMPLETED_NO);
        case ActionStatus.COMMITTED:
        case ActionStatus.H_COMMIT:
            destroyResource();
            break;
        case ActionStatus.ABORTED:
        case ActionStatus.H_ROLLBACK:
            if (TxControl.getMaintainHeuristics())
                destroyResource();
            throw new HeuristicRollback();
        case ActionStatus.H_MIXED:
            if (TxControl.getMaintainHeuristics())
                destroyResource();
            throw new HeuristicMixed();
        case ActionStatus.H_HAZARD:
            if (TxControl.getMaintainHeuristics())
                destroyResource();
            throw new HeuristicHazard();
        default:
            destroyResource();
            break;
    }
}
Also used : HeuristicRollback(org.omg.CosTransactions.HeuristicRollback) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) ServerTransaction(com.arjuna.ats.internal.jts.orbspecific.interposition.coordinator.ServerTransaction) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) NotPrepared(org.omg.CosTransactions.NotPrepared) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard)

Example 2 with HeuristicRollback

use of org.omg.CosTransactions.HeuristicRollback in project narayana by jbosstm.

the class XAResourceRecord method commit.

public void commit() throws org.omg.CORBA.SystemException, NotPrepared, HeuristicRollback, HeuristicMixed, HeuristicHazard {
    if (jtaxLogger.logger.isTraceEnabled()) {
        jtaxLogger.logger.trace("XAResourceRecord.commit for " + _tranID);
    }
    if (_tranID == null) {
        jtaxLogger.i18NLogger.warn_jtax_resources_jts_orbspecific_nulltransaction("XAResourceRecord.commit");
    } else {
        if ((_theXAResource != null) && (!_committed)) {
            switch(_heuristic) {
                case TwoPhaseOutcome.HEURISTIC_HAZARD:
                    throw new org.omg.CosTransactions.HeuristicHazard();
                case TwoPhaseOutcome.HEURISTIC_MIXED:
                    throw new org.omg.CosTransactions.HeuristicMixed();
                case TwoPhaseOutcome.HEURISTIC_ROLLBACK:
                    throw new org.omg.CosTransactions.HeuristicRollback();
                default:
                    break;
            }
            if (!_prepared)
                throw new NotPrepared();
            boolean removeConnection = true;
            try {
                if (!_committed) {
                    _committed = true;
                    _theXAResource.commit(_tranID, false);
                    destroyState();
                }
            } catch (XAException e1) {
                if (notAProblem(e1, true)) {
                    // some other thread got there first (probably)
                    destroyState();
                } else {
                    _committed = false;
                    jtaxLogger.i18NLogger.warn_jtax_resources_jts_orbspecific_xaerror("XAResourceRecord.commit", XAHelper.printXAErrorCode(e1), _theXAResource.toString(), XAHelper.xidToString(_tranID), e1);
                    if (jtaxLogger.logger.isTraceEnabled()) {
                        jtaxLogger.logger.tracef("XAResourceRecord.commit exception %s " + "resource_trace: txn uid=%s resource uid=%s\n", XAHelper.printXAErrorCode(e1), _tranID, get_uid());
                    }
                    switch(e1.errorCode) {
                        case XAException.XA_HEURHAZ:
                            updateState(TwoPhaseOutcome.HEURISTIC_HAZARD);
                            throw new org.omg.CosTransactions.HeuristicHazard();
                        case // what about forget? OTS doesn't support this code here.
                        XAException.XA_HEURCOM:
                            destroyState();
                            break;
                        case XAException.XA_HEURRB:
                        case XAException.XA_RBROLLBACK:
                        case XAException.XA_RBCOMMFAIL:
                        case XAException.XA_RBDEADLOCK:
                        case XAException.XA_RBINTEGRITY:
                        case XAException.XA_RBOTHER:
                        case XAException.XA_RBPROTO:
                        case XAException.XA_RBTIMEOUT:
                        case XAException.XA_RBTRANSIENT:
                        case XAException.XAER_RMERR:
                            updateState(TwoPhaseOutcome.HEURISTIC_ROLLBACK);
                            throw new org.omg.CosTransactions.HeuristicRollback();
                        case XAException.XA_HEURMIX:
                            updateState(TwoPhaseOutcome.HEURISTIC_MIXED);
                            throw new org.omg.CosTransactions.HeuristicMixed();
                        case XAException.XAER_NOTA:
                            if (// committed previously on participant
                            _phaseTwoStarted)
                                break;
                            // RM unexpectedly lost track of the tx, outcome is uncertain
                            updateState(TwoPhaseOutcome.HEURISTIC_HAZARD);
                            throw new org.omg.CosTransactions.HeuristicHazard();
                        case XAException.XAER_PROTO:
                            // presumed abort (or we could be really paranoid and throw a heuristic)
                            throw new TRANSACTION_ROLLEDBACK();
                        case XAException.XA_RETRY:
                        case XAException.XAER_RMFAIL:
                            removeConnection = false;
                            // Since JBTM-2710 this is not right because it will mean that commit is not reattempted _committed = true;  // remember for recovery later.
                            throw // will cause log to be rewritten.
                            new UNKNOWN();
                        // resource manager failed, did it rollback?
                        case XAException.XAER_INVAL:
                        default:
                            throw new org.omg.CosTransactions.HeuristicHazard();
                    }
                }
            } catch (Exception e2) {
                _committed = false;
                jtaxLogger.i18NLogger.warn_jtax_resources_jts_orbspecific_generror("XAResourceRecord.commit", _theXAResource.toString(), XAHelper.xidToString(_tranID), e2);
                throw new UNKNOWN();
            } finally {
                _phaseTwoStarted = true;
                if (removeConnection) {
                    removeConnection();
                }
            }
        }
    }
}
Also used : XAException(javax.transaction.xa.XAException) HeuristicRollback(org.omg.CosTransactions.HeuristicRollback) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) NotPrepared(org.omg.CosTransactions.NotPrepared) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) SystemException(org.omg.CORBA.SystemException) XAException(javax.transaction.xa.XAException) NotSerializableException(java.io.NotSerializableException) HeuristicRollback(org.omg.CosTransactions.HeuristicRollback) UNKNOWN(org.omg.CORBA.UNKNOWN) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK)

Aggregations

HeuristicHazard (org.omg.CosTransactions.HeuristicHazard)2 HeuristicMixed (org.omg.CosTransactions.HeuristicMixed)2 HeuristicRollback (org.omg.CosTransactions.HeuristicRollback)2 NotPrepared (org.omg.CosTransactions.NotPrepared)2 ServerTransaction (com.arjuna.ats.internal.jts.orbspecific.interposition.coordinator.ServerTransaction)1 NotSerializableException (java.io.NotSerializableException)1 XAException (javax.transaction.xa.XAException)1 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)1 SystemException (org.omg.CORBA.SystemException)1 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)1 UNKNOWN (org.omg.CORBA.UNKNOWN)1