github-actions[bot] commented on code in PR #70282:
URL: https://github.com/apache/doris/pull/70282#discussion_r4617672123
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTVFCommand.java:
##########
@@ -98,65 +115,134 @@ public void run(ConnectContext ctx, StmtExecutor
executor) throws Exception {
executor.setPlanner(planner);
executor.checkBlockRules();
- // FE-side deletion of existing files (before BE execution)
- PhysicalPlan physicalPlan = planner.getPhysicalPlan();
- if (physicalPlan instanceof PhysicalTVFTableSink) {
- PhysicalTVFTableSink<?> tvfSink = (PhysicalTVFTableSink<?>)
physicalPlan;
- String sinkTvfName = tvfSink.getTvfName();
- Map<String, String> sinkProps = tvfSink.getProperties();
- boolean deleteExisting = Boolean.parseBoolean(
- sinkProps.getOrDefault("delete_existing_files", "false"));
+ return planner;
+ }
- if (deleteExisting && !"local".equals(sinkTvfName)) {
- deleteExistingFilesInFE(sinkTvfName, sinkProps);
- }
- }
+ @Override
+ public void run(ConnectContext ctx, StmtExecutor executor) throws
Exception {
+ ExecutionState execution = new ExecutionState();
+ executor.registerQueryCancellationCallback(() ->
execution.cancel(executor.getPendingCancelReason()));
+ execution.checkCanceled();
+ NereidsPlanner planner = preparePlan(ctx, executor);
+ execution.checkCanceled();
- // 3. Create coordinator
Coordinator coordinator = EnvFactory.getInstance().createCoordinator(
ctx, planner, ctx.getStatsErrorEstimator());
-
TUniqueId queryId = ctx.queryId();
- QeProcessorImpl.INSTANCE.registerQuery(queryId,
- new QueryInfo(ctx, "INSERT INTO TVF", coordinator));
-
+ boolean registered = false;
try {
- // Audit and cancellation must observe the same coordinator that
dispatches the fragments.
+ execution.activeCoordinator = coordinator;
executor.setCoord(coordinator);
- coordinator.exec();
-
- // Wait for completion
- int timeoutS = ctx.getExecTimeoutS();
- if (coordinator.join(timeoutS)) {
- if (!coordinator.isDone()) {
- coordinator.cancel(new Status(TStatusCode.INTERNAL_ERROR,
"Insert into TVF timeout"));
- ctx.getState().setError(ErrorCode.ERR_UNKNOWN_ERROR,
"Insert into TVF timeout");
- return;
+ QeProcessorImpl.INSTANCE.registerQuery(queryId,
+ new QueryInfo(ctx, "INSERT INTO TVF", coordinator));
+ registered = true;
+
+ synchronized (execution.executionLock) {
+ execution.checkCanceled();
+ deleteExistingFiles(planner);
Review Comment:
[P2] Keep recursive destination deletion off the cancellation lock
With `delete_existing_files=true`, this synchronized block holds
`executionLock` while `FileSystem.delete(..., true)` lists and deletes every S3
page. `ExecutionState.cancel()` then waits for that same lock, and the deletion
loop never checks cancellation. For a large prefix or slow endpoint, a direct
INSERT reaching its query timeout blocks the FE's single `ConnectScheduler`
timeout-checking thread until the entire deletion finishes, delaying timeout
enforcement for other connections; `DROP JOB` also waits despite using
`cancel(false)`. Keep synchronous cancellation independent of remote deletion,
with a cancellation-aware handoff/check before dispatch, and cover a blocked
filesystem delete. This is separate from the existing admission-token finding:
it happens before `coordinator.exec()` and remains after the token-publication
fix.
--
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]