Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,10 @@ private String getTabletWriteDetail(List<Replica> tabletSuccReplicas, List<Repli
return writeDetail;
}

private void checkTransactionStateBeforeCommit(Database db, List<Table> tableList, long transactionId,
/**
* @return true if the transaction need to commit, otherwise false
*/
private boolean checkTransactionStateBeforeCommit(Database db, List<Table> tableList, long transactionId,
boolean is2PC, TransactionState transactionState)
throws TransactionCommitFailedException {
if (transactionState == null) {
Expand All @@ -706,7 +709,7 @@ private void checkTransactionStateBeforeCommit(Database db, List<Table> tableLis
throw new TransactionCommitFailedException("transaction [" + transactionId
+ "] is already visible, not pre-committed.");
}
return;
return false;
}
if (transactionState.getTransactionStatus() == TransactionStatus.COMMITTED) {
if (LOG.isDebugEnabled()) {
Expand All @@ -716,7 +719,7 @@ private void checkTransactionStateBeforeCommit(Database db, List<Table> tableLis
throw new TransactionCommitFailedException("transaction [" + transactionId
+ "] is already committed, not pre-committed.");
}
return;
return false;
}

if (is2PC && transactionState.getTransactionStatus() == TransactionStatus.PREPARE) {
Expand Down Expand Up @@ -755,6 +758,7 @@ private void checkTransactionStateBeforeCommit(Database db, List<Table> tableLis
}
}
}
return true;
}

/**
Expand All @@ -780,7 +784,9 @@ public void commitTransaction(List<Table> tableList, long transactionId, List<Ta
readUnlock();
}

checkTransactionStateBeforeCommit(db, tableList, transactionId, is2PC, transactionState);
if (!checkTransactionStateBeforeCommit(db, tableList, transactionId, is2PC, transactionState)) {
return;
}

Set<Long> errorReplicaIds = Sets.newHashSet();
Set<Long> totalInvolvedBackends = Sets.newHashSet();
Expand Down Expand Up @@ -836,7 +842,9 @@ public void commitTransaction(long transactionId, List<Table> tableList,
"DebugPoint: DatabaseTransactionMgr.commitTransaction.failed");
}

checkTransactionStateBeforeCommit(db, tableList, transactionId, false, transactionState);
if (!checkTransactionStateBeforeCommit(db, tableList, transactionId, false, transactionState)) {
return;
}

// error replica may be duplicated for different sub transaction, but it's ok
Set<Long> errorReplicaIds = Sets.newHashSet();
Expand Down