morningman commented on a change in pull request #7473: URL: https://github.com/apache/incubator-doris/pull/7473#discussion_r803255419
########## File path: fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java ########## @@ -511,16 +521,112 @@ public void commitTransaction(List<Table> tableList, long transactionId, List<Ta LOG.warn("Failed to commit txn [{}]. " + "Tablet [{}] success replica num is {} < quorum replica num {} " + "while error backends {}", - transactionId, tablet.getId(), successReplicaNum, quorumReplicaNum, + transactionState.getTransactionId(), tablet.getId(), successReplicaNum, quorumReplicaNum, Joiner.on(",").join(errorBackendIdsForTablet)); - throw new TabletQuorumFailedException(transactionId, tablet.getId(), + throw new TabletQuorumFailedException(transactionState.getTransactionId(), tablet.getId(), successReplicaNum, quorumReplicaNum, errorBackendIdsForTablet); } } } } } + } + + public void commitTransaction2PC(long transactionId) throws UserException { + Database db = catalog.getDbOrMetaException(dbId); + TransactionState transactionState; + readLock(); + try { + transactionState = unprotectedGetTransactionState(transactionId); + } finally { + readUnlock(); + } + + if (transactionState == null) { + LOG.debug("transaction not found: {}", transactionId); + throw new TransactionCommitFailedException("transaction {" + transactionId + "} not found."); + } + + if (transactionState.getTransactionStatus() == TransactionStatus.ABORTED) { Review comment: All the following `if` condition can be merged to one: `if (status != PRECOMMITTED)` ########## File path: fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java ########## @@ -837,6 +956,30 @@ public void finishTransaction(long transactionId, Set<Long> errorReplicaIds) thr LOG.info("finish transaction {} successfully", transactionState); } + protected void unprotectedPreCommitTransaction2PC(TransactionState transactionState, Set<Long> errorReplicaIds, + Map<Long, Set<Long>> tableToPartition, Set<Long> totalInvolvedBackends, + Database db) { + // transaction state is modified during check if the transaction could committed + if (transactionState.getTransactionStatus() != TransactionStatus.PREPARE) { + return; + } + // update transaction state version + transactionState.setPreCommitTime(System.currentTimeMillis()); + transactionState.setTransactionStatus(TransactionStatus.PRECOMMITTED); + transactionState.setErrorReplicas(errorReplicaIds); + for (long tableId : tableToPartition.keySet()) { + TableCommitInfo tableCommitInfo = new TableCommitInfo(tableId); + for (long partitionId : tableToPartition.get(tableId)) { + OlapTable table = (OlapTable) db.getTableNullable(tableId); Review comment: table not used -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org