Skip to content

[fix](cloud) Reuse the original transaction on OLAP insert begin retries - #71016

Open
wyxxxcat wants to merge 1 commit into
apache:masterfrom
wyxxxcat:insert_begin_txn_idempotent
Open

wyxxxcat wants to merge 1 commit into
apache:masterfrom
wyxxxcat:insert_begin_txn_idempotent

Conversation

@wyxxxcat

@wyxxxcat wyxxxcat commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Background

In cloud mode, the FE asks Meta Service to begin a transaction before an OLAP INSERT writes any rows. Meta Service uses the label and request ID to recognize repeated begin requests for the same pending transaction.

What problem does this PR solve?

Issue Number: None
Related PR: None
PR Type: Bugfix

Problem Summary:

If Meta Service created the transaction but the FE lost the response, an internal RPC retry could fail the INSERT with TXN_LABEL_ALREADY_USED. The FE now sends the current query ID as the request ID and continues the INSERT with the original transaction ID when Meta Service recognizes the retry.

Details

  • Frequency: Intermittent. The first begin request must create the transaction and its response must be lost before the FE retries.
  • Root cause: Cloud OLAP INSERT omitted the request ID. On retry, Meta Service found the label but had no request ID to match against the pending transaction.
  • Why existing tests missed it: The Meta Service test supplies a request ID directly. The FE transaction manager test checks that a duplicate response raises an exception. Neither exercises recovery through the INSERT executor.
  • Fix: Pass ctx.queryId() to beginTransaction() in cloud mode. When Meta Service returns TXN_DUPLICATED_REQ, take the transaction ID from DuplicatedRequestException. A separate INSERT with the same label and a different query ID still gets a label conflict while the original transaction is pending.
  • Other paths and branches: Non-cloud INSERT keeps its existing behavior. The OLAP INSERT executor also omits the request ID on branch-3.1, branch-4.0, branch-4.1, and branch-4.2.

Testing

Compiled OlapInsertExecutor and its parent class locally with JDK 17 against cached FE dependencies. git diff --check passed. No FE unit tests or cluster regression tests were run.

Release note

Cloud OLAP INSERT now recovers from a lost begin-transaction response when its RPC retry finds the original pending transaction.

Check List (For Author)

  • Behavior changed: No
  • Does this need documentation: No
  • Pre-submission status: Partially verified: local compilation passed. End-to-end retry recovery was not tested.

AI Disclosure

  • Tool: OpenAI Codex (GPT-6)
  • Generated: This PR description.
  • Human review: Author review of this description is pending.

@wyxxxcat
wyxxxcat requested a review from sollhui November 25, 2026 08:05
@wyxxxcat
wyxxxcat force-pushed the insert_begin_txn_idempotent branch 3 times, most recently from 70b656b to 09b3dab Compare November 25, 2026 08:40
@apache apache deleted a comment from github-actions Bot Nov 25, 2026
@wyxxxcat
wyxxxcat force-pushed the insert_begin_txn_idempotent branch from 09b3dab to fa47763 Compare November 25, 2026 08:50
@wyxxxcat

Copy link
Copy Markdown
Collaborator Author

run buildall

@shuke987

Copy link
Copy Markdown
Contributor

run compile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants