Skip to content

Commit fc4f996

Browse files
committed
[fix](fe) Release maybe-committed TSO without advancing fence
### What problem does this PR solve? Issue Number: None Related PR: apache#67181, apache#67594 Problem Summary: A Meta Service KV_TXN_MAYBE_COMMITTED response means the underlying commit attempt is no longer in flight: it either committed or will never commit. Advancing the TSO fence before releasing this TSO adds an unnecessary Meta Service write. Release the tracked TSO directly for this response while retaining fence advancement for FE-to-Meta-Service RPC failures whose requests may still complete later. ### Release note None ### Check List (For Author) - Test: Unit Test - CloudCommittedTsoTest: 3 passed - Full `./build.sh -j32`: passed - Behavior changed: Yes. KV_TXN_MAYBE_COMMITTED releases its tracked TSO without advancing the fence. - Does this need documentation: No
1 parent 29f1335 commit fc4f996

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ private TransactionState commitTxn(CommitTxnRequest.Builder builder, List<Table>
944944
MetaServiceCode code = commitTxnResponse.getStatus().getCode();
945945
if (commitTxnRequest.hasCommitTso()) {
946946
if (code == MetaServiceCode.KV_TXN_MAYBE_COMMITTED) {
947-
Env.getCurrentEnv().getTSOService().fenceAndAbandonCommitTso(
947+
Env.getCurrentEnv().getTSOService().abandonCommitTso(
948948
commitTxnRequest.getDbId(), transactionId, commitTxnRequest.getCommitTso());
949949
} else if (code == MetaServiceCode.OK || code == MetaServiceCode.TXN_ALREADY_VISIBLE
950950
|| code == MetaServiceCode.TXN_ALREADY_ABORTED) {

‎fe/fe-core/src/test/java/org/apache/doris/cloud/transaction/CloudCommittedTsoTest.java‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void testOrdinarySubTransactionAndTwoPhaseCommitReuseTsoAcrossRpcRetries(
9393
}
9494

9595
@Test
96-
public void testUncertainCommitResultsAreFencedBeforeRelease() throws Exception {
96+
public void testRpcFailureIsFencedButMaybeCommittedIsReleased() throws Exception {
9797
Env env = Mockito.mock(Env.class);
9898
TSOService tsoService = Mockito.mock(TSOService.class);
9999
InternalCatalog catalog = Mockito.mock(InternalCatalog.class);
@@ -117,6 +117,9 @@ public void testUncertainCommitResultsAreFencedBeforeRelease() throws Exception
117117
() -> commit.invoke(new CloudGlobalTransactionMgr(),
118118
Cloud.CommitTxnRequest.newBuilder().setDbId(1).setTxnId(10),
119119
Collections.emptyList(), 10L, false, Collections.emptyList(), Collections.emptyList()));
120+
Mockito.verify(tsoService).fenceAndAbandonCommitTso(1, 10, 500);
121+
Mockito.clearInvocations(tsoService);
122+
120123
Mockito.doReturn(CommitTxnResponse.newBuilder()
121124
.setStatus(Cloud.MetaServiceResponseStatus.newBuilder()
122125
.setCode(MetaServiceCode.KV_TXN_MAYBE_COMMITTED))
@@ -125,9 +128,9 @@ public void testUncertainCommitResultsAreFencedBeforeRelease() throws Exception
125128
() -> commit.invoke(new CloudGlobalTransactionMgr(),
126129
Cloud.CommitTxnRequest.newBuilder().setDbId(1).setTxnId(10),
127130
Collections.emptyList(), 10L, false, Collections.emptyList(), Collections.emptyList()));
128-
Mockito.verify(tsoService, Mockito.times(2)).fenceAndAbandonCommitTso(1, 10, 500);
129-
Mockito.verify(tsoService, Mockito.never()).abandonCommitTso(Mockito.anyLong(), Mockito.anyLong(),
130-
Mockito.anyLong());
131+
Mockito.verify(tsoService).abandonCommitTso(1, 10, 500);
132+
Mockito.verify(tsoService, Mockito.never()).fenceAndAbandonCommitTso(
133+
Mockito.anyLong(), Mockito.anyLong(), Mockito.anyLong());
131134
}
132135
}
133136

0 commit comments

Comments
 (0)