Skip to content

[Bug] removeExpiredTxns conflict #27884

@user-GitHub-user

Description

@user-GitHub-user

Search before asking

  • I had searched in the issues and found no similar issues.

Version

What's Wrong?

Starting from17414, createTxnCleaner uses LatestTxnId to synchronize the transaction deletion of FE. Will the following situation occur or not?: LatestTxnId has been deleted by other operations, and it cannot been found in the two Deques. until the Deque entry is completely deleted. for example: LatestTxnId is deleted by cleanLabel first. I noticed that the EditLog record of the cleanLabel operation is not locked by transactionLock. Will this lead to inconsistent binglog synchronization?

public void replayBatchRemoveTransaction(BatchRemoveTransactionsOperationV2 operation) {
        writeLock();
        try {
            if (operation.getLatestTxnIdForShort() != -1) {
                while (!finalStatusTransactionStateDequeShort.isEmpty()) {
                    TransactionState transactionState = finalStatusTransactionStateDequeShort.pop();
                    clearTransactionState(transactionState.getTransactionId());
                    if (operation.getLatestTxnIdForShort() == transactionState.getTransactionId()) {
                        break;
                    }
                }
            }

            if (operation.getLatestTxnIdForLong() != -1) {
                while (!finalStatusTransactionStateDequeLong.isEmpty()) {
                    TransactionState transactionState = finalStatusTransactionStateDequeLong.pop();
                    clearTransactionState(transactionState.getTransactionId());
                    if (operation.getLatestTxnIdForLong() == transactionState.getTransactionId()) {
                        break;
                    }
                }
            }
        } finally {
            writeUnlock();
        }
    }
try {
            DatabaseTransactionMgr dbTxnMgr = Env.getCurrentGlobalTransactionMgr().getDatabaseTransactionMgr(dbId);
            dbTxnMgr.cleanLabel(label);
        } catch (AnalysisException e) {
            // just ignore, because we don't want to throw any exception here.
        }
        // 3. Log
        if (!isReplay) {
            CleanLabelOperationLog log = new CleanLabelOperationLog(dbId, label);
            Env.getCurrentEnv().getEditLog().logCleanLabel(log);
        }

What You Expected?

TransactionState 正常

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions