Skip to content

Commit c8d9172

Browse files
committed
[fix](fe) Fail the statement when FE rejects a final external-file report
### What problem does this PR solve? Issue Number: None Related PR: #69392 Problem Summary: When FE rejects a final external-file report (for example the Iceberg commit-location check finds a file outside the sink's commit location), QeProcessorImpl only answered BE with external_file_commit_data_accepted=false. The fragment was never marked done and the coordinator status was never set. BE treats the rejection as terminal: it removes the files and never resends the report. The coordinator join therefore kept waiting on the fragment latch until insert_timeout (4 hours by default), and the user saw a timeout instead of the real reason. Now QeProcessorImpl cancels the coordinator with the rejection reason before it answers BE. Both coordinators' cancel release the fragment latch, so the INSERT fails immediately with the validation error and the transaction is aborted. ### Release note None ### Check List (For Author) - Test: Unit Test (QeProcessorImplReportAckTest, run by CI) - Behavior changed: Yes. A rejected final external-file report now fails the statement immediately instead of waiting until timeout. - Does this need documentation: No
1 parent bec29aa commit c8d9172

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

‎fe/fe-core/src/main/java/org/apache/doris/qe/QeProcessorImpl.java‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,15 @@ public TReportExecStatusResult reportExecStatus(TReportExecStatusParams params,
324324
try {
325325
boolean accepted = info.getCoord().updateFragmentExecStatus(params);
326326
if (hasExternalCommitData && !accepted) {
327-
return rejectedExternalFileReport(result, "FE has not accepted the external-file report");
327+
return rejectExternalFileReport(info.getCoord(), result,
328+
"FE has not accepted the external-file report");
328329
}
329330
} catch (Exception e) {
330331
LOG.warn("Exception during handle report, response: {}, query: {}, instance: {}", result.toString(),
331332
DebugUtil.printId(params.query_id), DebugUtil.printId(params.fragment_instance_id), e);
332333
return hasExternalCommitData
333-
? rejectedExternalFileReport(result, "FE did not accept the external-file report")
334+
? rejectExternalFileReport(info.getCoord(), result,
335+
"FE did not accept the external-file report: " + e.getMessage())
334336
: result;
335337
}
336338
result.setStatus(new TStatus(TStatusCode.OK));
@@ -354,6 +356,14 @@ private static String externalFileReportKey(TReportExecStatusParams params) {
354356
+ params.getFragmentId() + ":" + params.getBackendId();
355357
}
356358

359+
// A rejected final report is terminal: BE drops its files and never resends it, so the statement
360+
// must fail now instead of waiting for a fragment that can no longer finish.
361+
private static TReportExecStatusResult rejectExternalFileReport(
362+
CoordInterface coord, TReportExecStatusResult result, String message) {
363+
coord.cancel(new Status(TStatusCode.INTERNAL_ERROR, message));
364+
return rejectedExternalFileReport(result, message);
365+
}
366+
357367
private static TReportExecStatusResult rejectedExternalFileReport(
358368
TReportExecStatusResult result, String message) {
359369
TStatus status = new TStatus(TStatusCode.INTERNAL_ERROR);

‎fe/fe-core/src/test/java/org/apache/doris/qe/QeProcessorImplReportAckTest.java‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.doris.qe;
1919

20+
import org.apache.doris.common.Status;
2021
import org.apache.doris.common.profile.ExecutionProfile;
2122
import org.apache.doris.planner.PlanFragmentId;
2223
import org.apache.doris.system.Backend;
@@ -34,6 +35,7 @@
3435
import org.junit.jupiter.api.AfterEach;
3536
import org.junit.jupiter.api.Assertions;
3637
import org.junit.jupiter.api.Test;
38+
import org.mockito.ArgumentCaptor;
3739
import org.mockito.Mockito;
3840

3941
import java.lang.reflect.Field;
@@ -82,17 +84,34 @@ void rejectsExternalReportWhenHandlerThrows() throws Exception {
8284

8385
Assertions.assertEquals(TStatusCode.INTERNAL_ERROR, result.getStatus().getStatusCode());
8486
Assertions.assertFalse(result.isExternalFileCommitDataAccepted());
87+
// BE drops the files of a rejected final report, so the statement must fail instead of waiting.
88+
Status cancelReason = verifyCancelled(coordinator);
89+
Assertions.assertEquals(TStatusCode.INTERNAL_ERROR, cancelReason.getErrorCode());
90+
Assertions.assertTrue(cancelReason.getErrorMsg().contains("injected acceptance failure"));
8591
}
8692

8793
@Test
8894
void rejectsExternalReportWhenHandlerDoesNotAcceptIt() throws Exception {
8995
TUniqueId queryId = new TUniqueId(12345, 4);
90-
register(queryId);
96+
Coordinator coordinator = register(queryId);
9197

9298
TReportExecStatusResult result = report(params(queryId));
9399

94100
Assertions.assertEquals(TStatusCode.INTERNAL_ERROR, result.getStatus().getStatusCode());
95101
Assertions.assertFalse(result.isExternalFileCommitDataAccepted());
102+
Assertions.assertEquals(TStatusCode.INTERNAL_ERROR, verifyCancelled(coordinator).getErrorCode());
103+
}
104+
105+
@Test
106+
void acceptedExternalReportDoesNotCancelCoordinator() throws Exception {
107+
TUniqueId queryId = new TUniqueId(12345, 8);
108+
Coordinator coordinator = register(queryId);
109+
Mockito.when(coordinator.updateFragmentExecStatus(Mockito.any())).thenReturn(true);
110+
111+
TReportExecStatusResult result = report(params(queryId));
112+
113+
Assertions.assertTrue(result.isExternalFileCommitDataAccepted());
114+
Mockito.verify(coordinator, Mockito.never()).cancel(Mockito.any());
96115
}
97116

98117
@Test
@@ -186,6 +205,12 @@ private Coordinator register(TUniqueId queryId) throws Exception {
186205
return coordinator;
187206
}
188207

208+
private static Status verifyCancelled(Coordinator coordinator) {
209+
ArgumentCaptor<Status> reason = ArgumentCaptor.forClass(Status.class);
210+
Mockito.verify(coordinator, Mockito.times(1)).cancel(reason.capture());
211+
return reason.getValue();
212+
}
213+
189214
private static TReportExecStatusParams params(TUniqueId queryId) {
190215
return new TReportExecStatusParams()
191216
.setQueryId(queryId)

0 commit comments

Comments
 (0)