if rollback succeeds, then return XA_RBROLLBACK, if rollback failed, then return XAER_RMERR
513756
public void commit(Xid xid, boolean onePhase) throws XAException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(this, tc, "commit", new Object[] 
                     {
                      ivManagedConnection,
                      AdapterUtil.toString(xid), 
                      onePhase ? "ONE PHASE" : "TWO PHASE" }
                            );

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { 
            String cId = null;
            try {
                cId = ivManagedConnection.mcf.getCorrelator(ivManagedConnection); 
            } catch (SQLException x) {
                // will just log the exception here and ignore it since its in trace
                Tr.debug(this, tc, "got an exception trying to get the correlator in commit, exception is: ", x);
            }
            if (cId != null) {
                StringBuffer stbuf = new StringBuffer(200);
                stbuf.append("Correlator: DB2, ID: ");
                stbuf.append(cId);
                if (xid != null) {
                    stbuf.append("Transaction ID : ");
                    stbuf.append(xid);
                }
                stbuf.append(" COMMIT");
                Tr.debug(this, tc, stbuf.toString());
            }
        }

        if (dsConfig.get().enableMultithreadedAccessDetection) 
            ivManagedConnection.detectMultithreadedAccess(); 

        if (!onePhase) {
            XAException xaX = new XAException(XAException.XA_RBPROTO);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(this, tc, "commit", xaX); 
            throw xaX;
        }

        boolean commitFailed = false;
        boolean rollbackFailed = false;
        boolean setStateFailed = false;

        // Reset so we can deferred enlist in a future global transaction. 
        ivManagedConnection.wasLazilyEnlistedInGlobalTran = false; 

        try {
            // If no work was done during the transaction, the autoCommit value may still
            // be on.  In this case, just no-op, since some drivers like ConnectJDBC 3.1
            // don't allow commit/rollback when autoCommit is on.  

            ivSqlConn.commit(); 
            ivStateManager.setState(WSStateManager.XA_COMMIT);
        } catch (SQLException sqeC)
        {
            FFDCFilter.processException(sqeC, "com.ibm.ws.rsadapter.spi.WSRdbOnePhaseXaResourceImpl.commit", "105", this);
            commitFailed = true;
            Tr.error(tc, "DSA_INTERNAL_ERROR", new Object[] { "Exception caught during commit on the OnePhaseXAResource", sqeC });

            // If no work was done during the transaction, the autoCommit value may still
            // be on.  In this case, just no-op, since some drivers like ConnectJDBC 3.1
            // don't allow commit/rollback when autoCommit is on.  

            try
            { // autoCommit is off
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())  
                    Tr.debug(this, tc, "issue a rollback due to commit failure");
                ivSqlConn.rollback();
            } catch (SQLException sqeR)
            {
                FFDCFilter.processException(sqeR, "com.ibm.ws.rsadapter.spi.WSRdbOnePhaseXaResourceImpl.commit", "197", this);
                rollbackFailed = true;
                Tr.error(tc, "DSA_INTERNAL_ERROR", new Object[] { "Exception caught during rollback on the OnePhaseXAResource after a commit failed", sqeR });
            }
            catch (java.lang.RuntimeException x)
            {
                FFDCFilter.processException(x, "com.ibm.ws.rsadapter.spi.WSRdbOnePhaseXaResourceImpl.commit", "204", this);
                rollbackFailed = true;
                Tr.error(tc, "DSA_INTERNAL_ERROR", new Object[] { "Exception caught during rollback on the OnePhaseXAResource after a commit failed", x });
            }

        } catch (TransactionException te) {
            //Exception means setState failed because it was invalid to set the state in this case
            FFDCFilter.processException(te, "com.ibm.ws.rsadapter.spi.WSRdbOnePhaseXaResourceImpl.commit", "123", this);
            Tr.error(tc, "INVALID_TX_STATE", new Object[] { "OnePhaseXAResource.commit()", ivManagedConnection.getTransactionStateAsString() });
            setStateFailed = false;

        }
        catch (java.lang.RuntimeException x)
        {
            FFDCFilter.processException(x, "com.ibm.ws.rsadapter.spi.WSRdbOnePhaseXaResourceImpl.commit", "221", this);
            Tr.error(tc, "DSA_INTERNAL_ERROR", new Object[] { "Exception caught during commit on the OnePhaseXAResource", x });

            XAException xae = new XAException(XAException.XA_HEURHAZ); // throwing Heurhaz sine we don't really know f the commit failed or not.             
            traceXAException(xae, currClass);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(this, tc, "commit", "Exception"); 
            throw xae;

        }

        if (rollbackFailed) {
            XAException xae = new XAException(XAException.XAER_RMERR);
            traceXAException(xae, currClass);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(this, tc, "commit", "Exception"); 
            throw xae;
        } else if (commitFailed) {
            XAException xae = new XAException(XAException.XA_HEURHAZ); //  we don't know if the commit really failed, or the failure in communication after the commit succeeded             
            traceXAException(xae, currClass);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(this, tc, "commit", "Exception"); 
            throw xae;
        } else if (setStateFailed) {
            XAException xae = new XAException(XAException.XAER_RMERR);
            traceXAException(xae, currClass);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(this, tc, "commit", "Exception"); 
            throw xae;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(this, tc, "commit"); 
    }
1350233
def rollback             (self, n=None):
		""""""
		
		if n is None:
			if self.haveSnapshots: return self.fromSnapshot(self.latestLink)
			else:                  return self.fromScratch()
		elif isinstance(n, int):
			loadSnapshotPath = self.getFullPathToSnapshot(n)
			assert(os.path.isdir(loadSnapshotPath))
			return self.__markLatest(n).fromSnapshot(loadSnapshotPath)
		else:
			raise ValueError("n must be int, or None!")
1135891
def action(args):
    
    log.info('loading reference package')

    r = refpkg.Refpkg(args.refpkg, create=False)

    # First check if we can do n rollbacks
    q = r.contents
    for i in range(args.n):
        if q['rollback'] is None:
            log.error('Cannot rollback {} changes; '
                      'refpkg only records {} changes.'.format(args.n, i))
            return 1
        else:
            q = q['rollback']

    for i in range(args.n):
        r.rollback()

    return 0
14655
def rollback(self):
        """"""
        for p in self._moves:
            logging.info("Moving to %s\n from %s", *p)

        for new_path, path in self._moves:
            try:
                logger.debug('Replacing %s from %s', new_path, path)
                if os.path.isfile(new_path):
                    os.unlink(new_path)
                elif os.path.isdir(new_path):
                    rmtree(new_path)
                renames(path, new_path)
            except OSError as ex:
                logger.error("Failed to restore %s", new_path)
                logger.debug("Exception: %s", ex)

        self.commit()
1243649
def returner(ret):
    '''
    
    '''
    try:
        with _get_serv(ret, commit=True) as cur:
            sql = '''INSERT INTO salt_returns
                    (fun, jid, return, id, success, full_ret)
                    VALUES (%s, %s, %s, %s, %s, %s)'''
            cur.execute(
                sql, (
                    ret['fun'],
                    ret['jid'],
                    salt.utils.json.dumps(ret['return']),
                    ret['id'],
                    ret.get('success', False),
                    salt.utils.json.dumps(ret)))
    except salt.exceptions.SaltMasterError:
        log.critical('Could not store return with postgres returner. PostgreSQL server unavailable.')
771121
def rollback(self):
        
        try:
            if self._autocommit:
                return

            if not self._conn or not self._conn.is_connected():
                return

            if not self._conn.tds72_transaction:
                return

            self._main_cursor._rollback(cont=True,
                                        isolation_level=self._isolation_level)
        except socket.error as e:
            if e.errno in (errno.ENETRESET, errno.ECONNRESET, errno.EPIPE):
                return
            self._conn.close()
            raise
        except ClosedConnectionError:
            pass
1254646
def returner(ret):
    '''
    
    '''
    try:
        with _get_serv(ret, commit=True) as cur:
            sql = '''INSERT INTO salt_returns
                    (fun, jid, return, id, success, full_ret, alter_time)
                    VALUES (%s, %s, %s, %s, %s, %s, to_timestamp(%s))'''

            cur.execute(sql, (ret['fun'], ret['jid'],
                              psycopg2.extras.Json(ret['return']),
                              ret['id'],
                              ret.get('success', False),
                              psycopg2.extras.Json(ret),
                              time.time()))
    except salt.exceptions.SaltMasterError:
        log.critical('Could not store return with pgjsonb returner. PostgreSQL server unavailable.')
1140427
def _check(self): # TODO: fix?
        """"""
        if self._returncode:
            rarfile.check_returncode(self, '')
        if self._remain != 0:
            raise rarfile.BadRarFile("Failed the read enough data")
54140
private function tryToRecoverFromFailedQuery($sql, $arguments, $load_mode, $return_mode)
    {
        switch ($this->link->errno) {

            // Non-transactional tables not rolled back!
            case 1196:
                return null;

            // Server gone away
            case 2006:
            case 2013:
                return $this->handleMySqlGoneAway($sql, $arguments, $load_mode, $return_mode);

            // Deadlock detection and retry
            case 1213:
                return $this->handleDeadlock();

            // Other error
            default:
                throw new QueryException($this->link->error, $this->link->errno);
        }
    }
1147606
public function rollBack() {
		if ($this->transactionManager === null) {
			$this->performRollBack();
			return;
		}
		
		if ($this->transactionManager->hasOpenTransaction()) {
			$this->transactionManager->getRootTransaction()->rollBack();
		}
	}
477368
async def rollback(self):
        """"""
        if not self._parent._is_active:
            return
        await self._do_rollback()
        self._is_active = False
904620
void rollback(Transaction tx) {
		ReversibleIterator<LogRecord> iter = new LogRecordIterator();
		LogSeqNum txUnDoNextLSN = null;
		while (iter.hasNext()) {
			LogRecord rec = iter.next();
			if (rec.txNumber() == txNum) {
				if (txUnDoNextLSN != null) {
					if (txUnDoNextLSN.compareTo(rec.getLSN()) != 1)
						continue;
				}
				if (rec.op() == OP_START)
					return;
				else if (rec instanceof LogicalEndRecord) {

					// Undo this Logical operation;
					rec.undo(tx);
					/*
					 * Extract the logicalStartLSN form rec by casting it as a
					 * LogicalEndRecord
					 */
					LogSeqNum logicalStartLSN = ((LogicalEndRecord) rec).getlogicalStartLSN();

					/*
					 * Save the Logical Start LSN to skip the log records
					 * between the end record and the start record
					 */
					txUnDoNextLSN = logicalStartLSN;

				} else
					rec.undo(tx);
			}
		}
	}
787248
@Override
    public void rollback(Xid xid) throws XAException {

        final boolean isTracingEnabled = TraceComponent.isAnyTracingEnabled();

        if (isTracingEnabled && tc.isEntryEnabled())
            Tr.entry(this, tc, "rollback");

        if (getMcWrapper().isMCAborted()) {
            Tr.exit(tc, "Connection was aborted. Exiting rollback.");
            return;
        }

        this.hasRollbackOccured = true;

        try {
            xaResource.rollback(xid);
        } catch (XAException e) {
            processXAException(e);
            com.ibm.ws.ffdc.FFDCFilter.processException(
                                                        e,
                                                        "com.ibm.ejs.j2c.XATransactionWrapper.rollback",
                                                        "755",
                                                        this);
            if (!mcWrapper.isStale()) {
                Tr.error(tc, "XA_RESOURCE_ADAPTER_OPERATION_ID_EXCP_J2CA0027", "rollback", xid, e, mcWrapper.gConfigProps.cfName);
            }
            if (isTracingEnabled && tc.isEntryEnabled())
                Tr.exit(this, tc, "rollback", e);
            throw e;
        } catch (Exception e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(
                                                        e,
                                                        "com.ibm.ejs.j2c.XATransactionWrapper.rollback",
                                                        "761",
                                                        this);
            if (!mcWrapper.shouldBeDestroyed()) {
                mcWrapper.markTransactionError();
                Tr.error(tc, "XA_RESOURCE_ADAPTER_OPERATION_ID_EXCP_J2CA0027", "rollback", xid, e, mcWrapper.gConfigProps.cfName);
            }
            XAException x = new XAException("Exception:" + e.toString());
            x.initCause(e);
            if (isTracingEnabled && tc.isEntryEnabled())
                Tr.exit(this, tc, "rollback", x);
            throw x;
        }

        if (isTracingEnabled && tc.isEntryEnabled())
            Tr.exit(this, tc, "rollback");
    }
696611
def rollback(self):
        

        try:
            self.check_connection()
        except NullDatabaseConnectionError:
            return

        logger.debug("rollback: path='{}'".format(self.database_path))

        self.connection.rollback()
1354814
def _txn_retry_loop(conn, callback):
    
    with conn.begin():
        while True:
            try:
                with _NestedTransaction(conn):
                    ret = callback(conn)
                    return ret
            except sqlalchemy.exc.DatabaseError as e:
                if isinstance(e.orig, psycopg2.OperationalError):
                    if e.orig.pgcode == psycopg2.errorcodes.SERIALIZATION_FAILURE:
                        continue
                raise
644539
function _rCallback (cb) {
        return function (err, res, data) {
            if (err) return cb(err);
            if (!res || res.statusCode > 400) return cb(data);

            cb(null, data);
        };
    }
918914
def rollback(self, sql=None):
        """"""
        self._transaction = False
        try:
            rollback = self._con.rollback
        except AttributeError:
            return self._con.query(sql or 'rollback')
        else:
            if sql:
                return rollback(sql=sql)
            else:
                return rollback()