alvarotuso opened a new pull request, #70905:
URL: https://github.com/apache/doris/pull/70905

   ### Background
   
   In cloud mode the FE keeps no transaction state, so `SHOW TRANSACTION WHERE 
id = N` and `WHERE label = '...'` look the transaction up in the meta service 
with `get_txn`, which takes an id or a label and returns the transaction's 
record. `CloudGlobalTransactionMgr.getTransactionState` wraps the lookup by id 
for many callers and returns null both when the transaction does not exist and 
when the lookup fails.
   
   ### What problem does this PR solve?
   
   Issue Number: #70586
   Related PR: #70726 (depends on), #41718 (introduced the bug)
   PR Type: Bugfix
   
   Problem Summary:
   
   In cloud mode, `SHOW TRANSACTION` answers "transaction with id N does not 
exist" when the meta-service lookup fails, although the transaction exists, so 
a client polling a load cannot tell the two apart. #70726 fixes the first of 
the two `get_txn` calls a label lookup makes; the second, and every lookup by 
id, still go through `getTransactionState`. This PR makes each lookup one 
`get_txn` call in which only `TXN_ID_NOT_FOUND` means "does not exist". It 
builds on #70726 and stays a draft until that merges.
   
   ### Details
   
   - **Frequency:** Intermittent: whenever `get_txn` fails, after 
`MetaServiceProxy`'s retries or with a code such as `KV_TXN_GET_ERR` or 
`MAX_QPS_LIMIT`. Not observed on the id path; found by code review. #70726 
reports the label variant on 4.2.0-rc03.
   - **Root cause:** `CloudGlobalTransactionMgr.getSingleTranInfo` resolves the 
id through `getTransactionState`, which catches `RpcException` and every non-OK 
response and returns null, the same value as for a missing transaction; 
`getSingleTranInfo` turns that null into "does not exist".
   - **Why existing tests missed it:** Unit tests: 
`CloudGlobalTransactionMgrTest` has no case for `getSingleTranInfo`; #70726 
adds cases for `getTransactionId` and `getTransactionIdByLabel` only. 
Regression: `query_p0/show/test_show_transaction.groovy` and 
`show_p0/test_show_txn_error_msg.groovy` check a found and a missing label 
against a healthy meta service, and none can make `get_txn` fail.
   - **Fix:** `getSingleTranInfo` and a new `getSingleTranInfoByLabel` each 
make one `get_txn` call, apply #70726's rule, and build the row from the record 
it returns. The fix stays in these SHOW-only methods rather than in 
`getTransactionState`, whose null result about 30 other callers rely on. 
Shared-nothing mode implements `getSingleTranInfoByLabel` with its current two 
in-memory lookups.
   - **Other paths and branches:** The other callers of `getTransactionState`, 
the commit path of #70586 among them, still turn a failed lookup into null; 
#70726 leaves them to a follow-up. Shared-nothing mode reads local memory and 
is not affected. The bug dates from #41718; `branch-3.1`, `branch-4.0`, 
`branch-4.1`, and `branch-4.2` have it. A cherry-pick needs #70726 first.
   
   ### Testing
   
   All run locally on the head of this branch:
   
   - `CloudGlobalTransactionMgrTest`, new cases for label and id: one `get_txn` 
call and no `get_txn_id`, a missing transaction, and five kinds of failure 
reported as errors; for id, also a sub-transaction id reading its parent.
   - The same id cases on #70726's head, without this fix (the label cases call 
the new method, so they were left out): all five cases of 
`testGetSingleTranInfoByIdFailsOnLookupError` fail with `errCode = 2, 
detailMessage = transaction with id 123535 does not exist`; the other three 
pass.
   - `GlobalTransactionMgrTest#testGetSingleTranInfoByLabel` (new): 
shared-nothing mode finds a label and reports a missing one.
   - The whole classes pass: `CloudGlobalTransactionMgrTest` (90, 71 of them 
from #70726), `GlobalTransactionMgrTest` (16), `ShowTransactionCommandTest` (1).
   - Not run: the regression suites on a cloud cluster.
   
   ### Notes for Reviewers
   
   - The first three commits are #70726's; this PR is its last commit. Until 
#70726 merges, review it at 
https://github.com/alvarotuso/doris/compare/133ce6ae781...show-txn-single-get-txn.
   - `getLatestTxnInfoByLabel` is the body of #70726's `getTransactionId`, 
moved unchanged so that its messages and tests stay as they are; 
`getTransactionId` now wraps it.
   - `getTxnInfoById` maps a sub-transaction id to its parent and does not 
retry on `KV_TXN_CONFLICT`, like `getTransactionState`.
   
   ### Release note
   
   Fix `SHOW TRANSACTION` in cloud mode reporting that a transaction does not 
exist when the meta-service lookup failed. Such failures are now reported as 
errors that carry the meta service's message.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Partially verified: not run on a cloud cluster; 
depends on #70726, which is still open
   
   ### AI Disclosure
   
   - Tool: Claude Code (Claude Opus 5.5)
   - Generated: code, tests, this description
   - Human review: The author reviewed the code.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to