[fix](DatabaseTransactionMgr) Fix clean label bug which may cause inconsitent editlog operation (#29198)
This commit is contained in:
@ -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() {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user