distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODatabaseDocumentDistributed.java
public boolean commit2pc(ODistributedRequestId transactionId, boolean local) {
    getStorageDistributed().resetLastValidBackup();
    ODistributedDatabase localDistributedDatabase = getStorageDistributed().getLocalDistributedDatabase();

    ONewDistributedTxContextImpl txContext = (ONewDistributedTxContextImpl) localDistributedDatabase.getTxContext(transactionId);

    if (txContext != null) {
      if (SUCCESS.equals(txContext.getStatus())) {
        try {
          txContext.commit(this);
          localDistributedDatabase.popTxContext(transactionId);
          OLiveQueryHook.notifyForTxChanges(this);
          OLiveQueryHookV2.notifyForTxChanges(this);
        } finally {
          OLiveQueryHook.removePendingDatabaseOps(this);
          OLiveQueryHookV2.removePendingDatabaseOps(this);
        }
        return true;
      } else if (TIMEDOUT.equals(txContext.getStatus())) {
        int nretry = getConfiguration().getValueAsInteger(DISTRIBUTED_CONCURRENT_TX_MAX_AUTORETRY);
        int delay = getConfiguration().getValueAsInteger(DISTRIBUTED_CONCURRENT_TX_AUTORETRY_DELAY);

        for (int i = 0; i < nretry; i++) {
          try {
            if (i > 0) {
              try {
                Thread.sleep(new Random().nextInt(delay));
              } catch (InterruptedException e) {
                OException.wrapException(new OInterruptedException(e.getMessage()), e);
              }
            }
            internalBegin2pc(txContext, local);
            txContext.setStatus(SUCCESS);
            break;
          } catch (ODistributedRecordLockedException | ODistributedKeyLockedException ex) {
            // Just retry
          } catch (Exception ex) {
            OLogManager.instance()
                .warn(ODatabaseDocumentDistributed.this, "Error beginning timed out transaction: %s ", ex, transactionId);
            break;
          }
        }
        if (!SUCCESS.equals(txContext.getStatus())) {
          txContext.destroy();
          localDistributedDatabase.popTxContext(transactionId);
          Orient.instance().submit(() -> {
            OLogManager.instance()
                .warn(ODatabaseDocumentDistributed.this, "Reached limit of retry for commit tx:%s forcing database re-install",
                    transactionId);
            distributedManager.installDatabase(false, ODatabaseDocumentDistributed.this.getName(), true, true);
          });
          return true;
        }
        try {
          txContext.commit(this);
          localDistributedDatabase.popTxContext(transactionId);
          OLiveQueryHook.notifyForTxChanges(this);
          OLiveQueryHookV2.notifyForTxChanges(this);
          return true;
        } finally {
          OLiveQueryHook.removePendingDatabaseOps(this);
          OLiveQueryHookV2.removePendingDatabaseOps(this);
        }

      } else {
        txContext.destroy();
        localDistributedDatabase.popTxContext(transactionId);
        Orient.instance().submit(() -> {
          OLogManager.instance()
              .warn(ODatabaseDocumentDistributed.this, "Reached limit of retry for commit tx:%s forcing database re-install",
                  transactionId);
          distributedManager.installDatabase(false, ODatabaseDocumentDistributed.this.getName(), true, true);
        });
        return true;
      }
    }
    return false;
  }
public boolean commit2pc(ODistributedRequestId transactionId, boolean local) {
    getStorageDistributed().resetLastValidBackup();
    ODistributedDatabase localDistributedDatabase = getStorageDistributed().getLocalDistributedDatabase();

    ONewDistributedTxContextImpl txContext = (ONewDistributedTxContextImpl) localDistributedDatabase.getTxContext(transactionId);

    if (txContext != null) {
      if (SUCCESS.equals(txContext.getStatus())) {
        try {
          txContext.commit(this);
          localDistributedDatabase.popTxContext(transactionId);
          OLiveQueryHook.notifyForTxChanges(this);
          OLiveQueryHookV2.notifyForTxChanges(this);
        } finally {
          OLiveQueryHook.removePendingDatabaseOps(this);
          OLiveQueryHookV2.removePendingDatabaseOps(this);
        }
        return true;
      } else if (TIMEDOUT.equals(txContext.getStatus())) {
        int nretry = getConfiguration().getValueAsInteger(DISTRIBUTED_CONCURRENT_TX_MAX_AUTORETRY);
        int delay = getConfiguration().getValueAsInteger(DISTRIBUTED_CONCURRENT_TX_AUTORETRY_DELAY);

        for (int i = 0; i < nretry; i++) {
          try {
            if (i > 0) {
              try {
                Thread.sleep(new Random().nextInt(delay));
              } catch (InterruptedException e) {
                OException.wrapException(new OInterruptedException(e.getMessage()), e);
              }
            }
            internalBegin2pc(txContext, local);
            txContext.setStatus(SUCCESS);
            break;
          } catch (ODistributedRecordLockedException | ODistributedKeyLockedException ex) {
            // Just retry
          } catch (Exception ex) {
            OLogManager.instance()
                .warn(ODatabaseDocumentDistributed.this, "Error beginning timed out transaction: %s ", ex, transactionId);
            break;
          }
        }
        if (!SUCCESS.equals(txContext.getStatus())) {
          txContext.destroy();
          localDistributedDatabase.popTxContext(transactionId);
          Orient.instance().submit(() -> {
            OLogManager.instance()
                .warn(ODatabaseDocumentDistributed.this, "Reached limit of retry for commit tx:%s forcing database re-install",
                    transactionId);
            distributedManager.installDatabase(false, ODatabaseDocumentDistributed.this.getName(), true, true);
          });
          return true;
        }
        try {
          txContext.commit(this);
          localDistributedDatabase.popTxContext(transactionId);
          OLiveQueryHook.notifyForTxChanges(this);
          OLiveQueryHookV2.notifyForTxChanges(this);
          return true;
        } finally {
          OLiveQueryHook.removePendingDatabaseOps(this);
          OLiveQueryHookV2.removePendingDatabaseOps(this);
        }

      } else {
        txContext.destroy();
        localDistributedDatabase.popTxContext(transactionId);
        Orient.instance().submit(() -> {
          OLogManager.instance()
              .warn(ODatabaseDocumentDistributed.this, "Reached limit of retry for commit tx:%s forcing database re-install",
                  transactionId);
          distributedManager.installDatabase(false, ODatabaseDocumentDistributed.this.getName(), true, true);
        });
        return true;
      }
    }
    return false;
  }
public boolean commit2pc ( ODistributedRequestId transactionId , boolean local ) { getStorageDistributed ( ) . resetLastValidBackup ( ) ; ODistributedDatabase localDistributedDatabase = getStorageDistributed ( ) . getLocalDistributedDatabase ( ) ; ONewDistributedTxContextImpl txContext = ( ONewDistributedTxContextImpl ) localDistributedDatabase . getTxContext ( transactionId ) ; if ( txContext != null ) { if ( SUCCESS . equals ( txContext . getStatus ( ) ) ) { try { txContext . commit ( this ) ; localDistributedDatabase . popTxContext ( transactionId ) ; OLiveQueryHook . notifyForTxChanges ( this ) ; OLiveQueryHookV2 . notifyForTxChanges ( this ) ; } finally { OLiveQueryHook . removePendingDatabaseOps ( this ) ; OLiveQueryHookV2 . removePendingDatabaseOps ( this ) ; } return true ; } else if ( TIMEDOUT . equals ( txContext . getStatus ( ) ) ) { int nretry = getConfiguration ( ) . getValueAsInteger ( DISTRIBUTED_CONCURRENT_TX_MAX_AUTORETRY ) ; int delay = getConfiguration ( ) . getValueAsInteger ( DISTRIBUTED_CONCURRENT_TX_AUTORETRY_DELAY ) ; for ( int i = 0 ; i < nretry ; i ++ ) { try { if ( i > 0 ) { try { Thread . sleep ( new Random ( ) . nextInt ( delay ) ) ; } catch ( InterruptedException e ) { OException . wrapException ( new OInterruptedException ( e . getMessage ( ) ) , e ) ; } } internalBegin2pc ( txContext , local ) ; txContext . setStatus ( SUCCESS ) ; break ; } catch ( ODistributedRecordLockedException | ODistributedKeyLockedException ex ) { // Just retry } catch ( Exception ex ) { OLogManager . instance ( ) . warn ( ODatabaseDocumentDistributed . this , "Error beginning timed out transaction: %s " , ex , transactionId ) ; break ; } } if ( ! SUCCESS . equals ( txContext . getStatus ( ) ) ) { txContext . destroy ( ) ; localDistributedDatabase . popTxContext ( transactionId ) ; Orient . instance ( ) . submit ( ( ) -> { OLogManager . instance ( ) . warn ( ODatabaseDocumentDistributed . this , "Reached limit of retry for commit tx:%s forcing database re-install" , transactionId ) ; distributedManager . installDatabase ( false , ODatabaseDocumentDistributed . this . getName ( ) , true , true ) ; } ) ; return true ; } try { txContext . commit ( this ) ; localDistributedDatabase . popTxContext ( transactionId ) ; OLiveQueryHook . notifyForTxChanges ( this ) ; OLiveQueryHookV2 . notifyForTxChanges ( this ) ; return true ; } finally { OLiveQueryHook . removePendingDatabaseOps ( this ) ; OLiveQueryHookV2 . removePendingDatabaseOps ( this ) ; } } else { txContext . destroy ( ) ; localDistributedDatabase . popTxContext ( transactionId ) ; Orient . instance ( ) . submit ( ( ) -> { OLogManager . instance ( ) . warn ( ODatabaseDocumentDistributed . this , "Reached limit of retry for commit tx:%s forcing database re-install" , transactionId ) ; distributedManager . installDatabase ( false , ODatabaseDocumentDistributed . this . getName ( ) , true , true ) ; } ) ; return true ; } } return false ; }
@param transactionId

@return null returned means that commit failed
@param transactionId