This is an automated email from the ASF dual-hosted git repository.
caiconghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 4f2d54d462a [fix](DatabaseTransactionMgr) Fix clean label bug which
may cause inconsitent editlog operation (#29198)
4f2d54d462a is described below
commit 4f2d54d462a680268349e8b167bdab96ed6eef2c
Author: caiconghui <[email protected]>
AuthorDate: Thu Dec 28 14:17:35 2023 +0800
[fix](DatabaseTransactionMgr) Fix clean label bug which may cause
inconsitent editlog operation (#29198)
---
.../main/java/org/apache/doris/load/loadv2/LoadManager.java | 12 +++---------
.../org/apache/doris/transaction/DatabaseTransactionMgr.java | 10 +++++++---
.../org/apache/doris/transaction/GlobalTransactionMgr.java | 4 ++--
3 files changed, 12 insertions(+), 14 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java
b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java
index 3909ff5d784..35968139ec8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java
@@ -786,22 +786,16 @@ public class LoadManager implements Writable {
} finally {
writeUnlock();
}
- LOG.info("clean {} labels on db {} with label '{}' in load mgr.",
counter, dbId, label);
-
// 2. Remove from DatabaseTransactionMgr
try {
- Env.getCurrentGlobalTransactionMgr().cleanLabel(dbId, label);
+ Env.getCurrentGlobalTransactionMgr().cleanLabel(dbId, label,
isReplay);
} catch (AnalysisException e) {
// just ignore, because we don't want to throw any exception here.
LOG.warn("Exception:", e);
}
- // 3. Log
- if (!isReplay) {
- CleanLabelOperationLog log = new CleanLabelOperationLog(dbId,
label);
- Env.getCurrentEnv().getEditLog().logCleanLabel(log);
- }
- LOG.info("finished to clean label on db {} with label {}. is replay:
{}", dbId, label, isReplay);
+ LOG.info("finished to clean {} labels on db {} with label '{}' in load
mgr. is replay: {}",
+ counter, dbId, label, isReplay);
}
private void readLock() {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
b/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
index 29471255f29..5bb954289cc 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
@@ -50,6 +50,7 @@ import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.metric.MetricRepo;
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.persist.BatchRemoveTransactionsOperationV2;
+import org.apache.doris.persist.CleanLabelOperationLog;
import org.apache.doris.persist.EditLog;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.statistics.AnalysisManager;
@@ -2072,7 +2073,7 @@ public class DatabaseTransactionMgr {
}
}
- protected void cleanLabel(String label) {
+ protected void cleanLabel(String label, boolean isReplay) {
Set<Long> removedTxnIds = Sets.newHashSet();
writeLock();
try {
@@ -2113,11 +2114,14 @@ public class DatabaseTransactionMgr {
// So that we can keep consistency in meta image
finalStatusTransactionStateDequeShort.removeIf(txn ->
removedTxnIds.contains(txn.getTransactionId()));
finalStatusTransactionStateDequeLong.removeIf(txn ->
removedTxnIds.contains(txn.getTransactionId()));
+
+ if (!isReplay) {
+ CleanLabelOperationLog log = new CleanLabelOperationLog(dbId,
label);
+ Env.getCurrentEnv().getEditLog().logCleanLabel(log);
+ }
} finally {
writeUnlock();
}
- LOG.info("clean {} labels on db {} with label '{}' in database
transaction mgr.", removedTxnIds.size(), dbId,
- label);
}
public long getTxnNumByStatus(TransactionStatus status) {
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 ee228a10fc8..4832d66bedb 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
@@ -754,8 +754,8 @@ public class GlobalTransactionMgr implements Writable {
return getDatabaseTransactionMgr(dbId).getPreCommittedTxnList();
}
- public void cleanLabel(Long dbId, String label) throws AnalysisException {
- getDatabaseTransactionMgr(dbId).cleanLabel(label);
+ public void cleanLabel(Long dbId, String label, boolean isReplay) throws
AnalysisException {
+ getDatabaseTransactionMgr(dbId).cleanLabel(label, isReplay);
}
public Long getTransactionIdByLabel(Long dbId, String label,
List<TransactionStatus> statusList)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]