Skip to content

Commit

Permalink
[fix](transaction load) transaction may publish stuck if fe restart (#…
Browse files Browse the repository at this point in the history
…44190)

1. a transaction for txn load is committed and not published
2. restart FE
3. the `subTxnIdToTxnId` in `DatabaseTransactionMgr` is empty, not
record the map of sub txn_id to txn_id
4. if BE report tablet and txn infos, FE will get transaction state to
judge if the txn load info in BE can be removed, but get txnId is null
from `subTxnIdToTxnId`, so be remove the txn load info
5. the publish will fail because `publish version failed on transaction,
tablet version not exists`
  • Loading branch information
mymeiyi authored Nov 19, 2024
1 parent 7aec6ff commit d1b2b1b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,14 @@ protected void unprotectUpsertTransactionState(TransactionState transactionState
if (idToRunningTransactionState.put(transactionState.getTransactionId(), transactionState) == null) {
runningTxnNums++;
}
if (isReplay && transactionState.getSubTxnIds() != null) {
LOG.info("add sub transactions for txn_id={}, status={}, sub_txn_ids={}",
transactionState.getTransactionId(), transactionState.getTransactionStatus(),
transactionState.getSubTxnIds());
for (Long subTxnId : transactionState.getSubTxnIds()) {
addSubTransaction(transactionState.getTransactionId(), subTxnId);
}
}
} else {
if (idToRunningTransactionState.remove(transactionState.getTransactionId()) != null) {
runningTxnNums--;
Expand All @@ -1670,6 +1678,11 @@ protected void unprotectUpsertTransactionState(TransactionState transactionState
} else {
finalStatusTransactionStateDequeLong.add(transactionState);
}
if (transactionState.getSubTxnIds() != null) {
LOG.info("clean sub transactions for txn_id={}, sub_txn_ids={}", transactionState.getTransactionId(),
transactionState.getSubTxnIds());
cleanSubTransactions(transactionState.getTransactionId());
}
}
updateTxnLabels(transactionState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,13 @@ public void testSubTransaction() throws UserException {
long subTransactionId3 = transactionState6.getSubTxnIds().get(2);
TransactionState subTransactionState = masterTransMgr.getTransactionState(CatalogTestUtil.testDbId1,
subTransactionId3);
Assert.assertEquals(transactionState6, subTransactionState);
Assert.assertEquals(null, subTransactionState); // finished txn will remove sub txn map
// test show transaction state command
List<List<String>> singleTranInfos = masterDbTransMgr.getSingleTranInfo(CatalogTestUtil.testDbId1,
/*List<List<String>> singleTranInfos = masterDbTransMgr.getSingleTranInfo(CatalogTestUtil.testDbId1,
subTransactionId3);
Assert.assertEquals(1, singleTranInfos.size());
List<String> txnInfo = singleTranInfos.get(0);
Assert.assertEquals(String.valueOf(transactionId6), txnInfo.get(0));
Assert.assertEquals(String.valueOf(transactionId6), txnInfo.get(0));*/

// test get table transaction info: table_id to partition_id map
List<List<Comparable>> tableTransInfos = masterDbTransMgr.getTableTransInfo(transactionId6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ suite("txn_insert_restart_fe", 'docker') {
options.feConfigs.add('sys_log_verbose_modules=org.apache.doris')
// options.beConfigs.add('sys_log_verbose_modules=*')
options.beConfigs.add('enable_java_support=false')
options.beConfigs.add('pending_data_expire_time_sec=1')
docker(options) {
// ---------- test restart fe ----------
def result = sql 'SELECT DATABASE()'
Expand Down

0 comments on commit d1b2b1b

Please sign in to comment.