Skip to content

Commit

Permalink
[Enhancement] Add more detailed logging for commit transaction scenar…
Browse files Browse the repository at this point in the history
…ios. (#49083)

Fixes #49084

Add more detailed logging for commit transaction scenarios.

Signed-off-by: edwinhzhang <[email protected]>
(cherry picked from commit 9a6256d)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/transaction/GlobalTransactionMgr.java
  • Loading branch information
zhangheihei authored and mergify[bot] committed Jul 30, 2024
1 parent 6f22e32 commit 4782402
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public enum ReplicaStatus {
// 1. tablet has 2 replica A has version[7,8,9,10], B: [7,8,9,10]
// 2. a newly cloned replica C full clone from replica A, then has version [10]
// 3. current partition visible version is still 9
// 4. A query read this tablet at version 9, and picks replica C, but replica C doesn't have version 10,
// 4. A query read this tablet at version 9, and picks replica C, but replica C only have version 10,
// causing `version not found` error
@SerializedName(value = "minReadableVersion")
private volatile long minReadableVersion = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,22 @@ public void commitPreparedTransaction(Database db, long transactionId, long time
VisibleStateWaiter waiter;
StopWatch stopWatch = new StopWatch();
stopWatch.start();
<<<<<<< HEAD
if (!db.tryWriteLock(timeoutMillis, TimeUnit.MILLISECONDS)) {
throw new UserException("get database write lock timeout, database="
+ db.getFullName() + ", timeoutMillis=" + timeoutMillis);
=======

TransactionState transactionState = getTransactionState(db.getId(), transactionId);
List<Long> tableIdList = transactionState.getTableIdList();

Locker locker = new Locker();
if (!locker.tryLockTablesWithIntensiveDbLock(db, tableIdList, LockType.WRITE,
timeoutMillis, TimeUnit.MILLISECONDS)) {
String errMsg = String.format("get database write lock timeout, transactionId=%d, database=%s, timeoutMillis=%d",
transactionId, db.getFullName(), timeoutMillis);
throw new UserException(errMsg);
>>>>>>> 9a6256d6ba ([Enhancement] Add more detailed logging for commit transaction scenarios. (#49083))
}
try {
waiter = getDatabaseTransactionMgr(db.getId()).commitPreparedTransaction(transactionId);
Expand All @@ -426,10 +439,14 @@ public void commitPreparedTransaction(Database db, long transactionId, long time
if (publishTimeoutMillis < 0) {
// here commit transaction successfully cost too much time to cause publisTimeoutMillis is less than zero,
// so we just return false to indicate publish timeout
throw new UserException("publish timeout: " + timeoutMillis);
String errMsg = String.format("publish timeout: %d, transactionId=%d",
timeoutMillis, transactionId);
throw new UserException(errMsg);
}
if (!waiter.await(publishTimeoutMillis, TimeUnit.MILLISECONDS)) {
throw new UserException("publish timeout: " + timeoutMillis);
String errMsg = String.format("publish timeout: %d, transactionId=%d",
timeoutMillis, transactionId);
throw new UserException(errMsg);
}
}

Expand Down

0 comments on commit 4782402

Please sign in to comment.