From 127cd9ef441ec227b80a42b7fec29ab7958f6a01 Mon Sep 17 00:00:00 2001 From: Lchangliang <915311741@qq.com> Date: Mon, 29 Jul 2024 15:29:55 +0800 Subject: [PATCH] tmp --- cloud/src/meta-service/meta_service_txn.cpp | 2 +- .../transaction/GlobalTransactionMgr.java | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cloud/src/meta-service/meta_service_txn.cpp b/cloud/src/meta-service/meta_service_txn.cpp index 29190c06330720..15634ba2a8b431 100644 --- a/cloud/src/meta-service/meta_service_txn.cpp +++ b/cloud/src/meta-service/meta_service_txn.cpp @@ -2617,7 +2617,7 @@ void MetaServiceImpl::abort_txn_with_coordinator(::google::protobuf::RpcControll while (it->has_next()) { total_iteration_cnt++; auto [k, v] = it->next(); - LOG(INFO) << "check txn info txn_info_key=" << hex(k); + VLOG_DEBUG << "check txn info txn_info_key=" << hex(k); TxnInfoPB info_pb; if (!info_pb.ParseFromArray(v.data(), v.size())) { code = MetaServiceCode::PROTOBUF_PARSE_ERR; diff --git a/fe/fe-core/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java b/fe/fe-core/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java index a5e84129de08af..57ee12fe86c20e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java @@ -446,32 +446,35 @@ public boolean existCommittedTxns(Long dbId, Long tableId, Long partitionId) { public static boolean checkFailedTxnsByCoordinator(TransactionState txn) { TxnCoordinator coordinator = txn.getCoordinator(); + boolean offline = true; if (coordinator.sourceType == TransactionState.TxnSourceType.FE) { List frontends = Env.getCurrentEnv().getFrontends(null); for (Frontend fe : frontends) { - if (fe.getHost().equals(coordinator.ip) && fe.getLastStartupTime() > coordinator.startTime) { - return true; + if (fe.getHost().equals(coordinator.ip)) { + offline = false; + if (fe.getLastStartupTime() > coordinator.startTime) { + return true; + } } } } else if (coordinator.sourceType == TransactionState.TxnSourceType.BE) { Backend be = Env.getCurrentSystemInfo().getBackend(coordinator.id); - if (be.getHost().equals(coordinator.ip) && (be.getLastStartTime() > coordinator.startTime - || (!be.isAlive() && System.currentTimeMillis() - be.getLastUpdateMs() - >= Config.abort_txn_after_lost_heartbeat_time_second * 1000L))) { - return true; + if (be != null) { + offline = false; + if (be.getHost().equals(coordinator.ip) && (be.getLastStartTime() > coordinator.startTime + || (!be.isAlive() && System.currentTimeMillis() - be.getLastUpdateMs() + >= Config.abort_txn_after_lost_heartbeat_time_second * 1000L))) { + return true; + } } } - return false; + return offline; } public static List checkFailedTxns(List conflictTxns) { List failedTxns = new ArrayList<>(); for (TransactionState txn : conflictTxns) { - boolean failed = false; - if (!failed) { - failed = checkFailedTxnsByCoordinator(txn); - } - if (failed) { + if (checkFailedTxnsByCoordinator(txn)) { failedTxns.add(txn); } }