hello-stephen commented on code in PR #71217:
URL: https://github.com/apache/doris/pull/71217#discussion_r4750817177
##########
fe/fe-core/src/main/java/org/apache/doris/alter/IndexChangeJob.java:
##########
@@ -173,6 +173,18 @@ public void setAlterInvertedIndexInfo(boolean isDropOp,
List<Index> alterInverte
this.alterInvertedIndexes = alterInvertedIndexes;
}
+ public boolean isDropOp() {
+ return isDropOp;
+ }
+
+ // Whether a BE may still run a task of this cancelled job: cancelling
does not stop the requests a BE has
+ // received, so their tasks stay in AgentTaskQueue until the BE reports
them or no longer holds them.
+ public boolean hasPendingTasks() {
+ return jobState == JobState.CANCELLED
+ && invertedIndexBatchTask.getAllTasks().stream()
Review Comment:
[P1] Preserve the pending-task barrier across FE replay
`invertedIndexBatchTask` does not retain its tasks in the journal:
`AgentBatchTask.backendIdToTasks` has no `@SerializedName`, so `GsonUtils`
excludes it and the batch serializes as `{}`.
`SchemaChangeHandler.replayIndexChangeJob` replaces the job with the
deserialized object, and `replayCancelled` neither reconstructs the batch nor
restores `AgentTaskQueue` entries. If FE fails over after cancelling a DROP
whose BE work is still pending, this stream is empty and the new leader admits
an opposite BUILD. A surviving DROP that executes later can remove that index.
Please persist/reconstruct the cancellation barrier, or establish an equivalent
BE-side fence, and add a cancelled-job replay/failover test.
##########
fe/fe-core/src/main/java/org/apache/doris/alter/IndexChangeJob.java:
##########
@@ -173,6 +173,18 @@ public void setAlterInvertedIndexInfo(boolean isDropOp,
List<Index> alterInverte
this.alterInvertedIndexes = alterInvertedIndexes;
}
+ public boolean isDropOp() {
+ return isDropOp;
+ }
+
+ // Whether a BE may still run a task of this cancelled job: cancelling
does not stop the requests a BE has
+ // received, so their tasks stay in AgentTaskQueue until the BE reports
them or no longer holds them.
+ public boolean hasPendingTasks() {
+ return jobState == JobState.CANCELLED
+ && invertedIndexBatchTask.getAllTasks().stream()
+ .anyMatch(task -> !task.isFinished() &&
AgentTaskQueue.contains(task));
Review Comment:
[P2] Keep the barrier independent of inactive-backend task eviction
`AgentTaskCleanupDaemon` removes non-publish tasks after three failed
backend-liveness checks and `AgentTaskQueue.abortTask` sets them finished. A
heartbeat RPC outage can trigger this without stopping the BE process or its
queued index work. After heartbeats recover, this predicate therefore returns
false even though the cancelled DROP remains runnable. The local alter pool has
three workers by default, so a pending DROP delayed before its tablet lock can
execute after a newly admitted BUILD and remove its index; `checkTableStable`
does not check these tasks. Please retain the cancellation barrier across
liveness-only eviction and release it only on completion or evidence the old BE
work cannot run, such as a confirmed process restart.
##########
fe/fe-core/src/main/java/org/apache/doris/task/AgentBatchTask.java:
##########
@@ -187,6 +187,9 @@ public void run() {
address = new TNetworkAddress(host, backend.getBePort());
client = ClientPool.backendPool.borrowObject(address);
for (AgentTask task : tasks) {
+ if (task.isCancelled()) {
Review Comment:
[P1] Fence senders that already passed the cancellation check
A resend can pass this check and buffer its `TAgentTaskRequest`, then pause
before `submitTasks`. If the job is cancelled and the original DROP finishes
meanwhile, `MasterImpl.finishAlterInvertedIndexTask` marks the task
finished/removes it, so `hasPendingTasks()` allows BUILD immediately. The
buffered resend can then arrive after BUILD completes. BE deduplication only
covers currently registered signatures (`remove_task_info` erases the original
on completion), so this late DROP is accepted again and removes the newly built
index. The volatile flag does not fence a request already converted. Please
drain/fence in-progress submissions before releasing the cancellation barrier,
or reject obsolete jobs at BE. A test paused after conversion would cover this;
the added test starts the sender only after cancellation.
##########
fe/fe-core/src/main/java/org/apache/doris/master/ReportHandler.java:
##########
@@ -764,6 +764,14 @@ private static void taskReport(long backendId,
Map<TTaskType, Set<Long>> running
AgentBatchTask batchTask = new
AgentBatchTask(Config.report_resend_batch_task_num_per_rpc);
long taskReportTime = System.currentTimeMillis();
for (AgentTask task : diffTasks) {
+ if (task.isCancelled()) {
+ // The BE does not hold this cancelled task. A request sent
before the cancel has arrived or failed
+ // once the RPC timeout has passed, so after that the BE will
not run the task.
+ if (taskReportTime - task.getCancelTimeMs() >=
Config.backend_rpc_timeout_ms) {
Review Comment:
[P1] Establish report freshness before removing cancelled tasks
`taskReportTime` is the FE processing time, not the time the BE captured
`runningTasks`. A snapshot taken before DROP was registered can arrive or be
processed after the cancellation timeout while that DROP is still pending. In
particular, `MasterServerClient::report` retries the same snapshot after a
transport error, and `ReportTask` carries no snapshot time or ordering token.
This branch then removes the live task and admits BUILD; an old DROP worker
that has not acquired the tablet lock can execute afterward and undo BUILD.
Waiting one RPC timeout from cancellation does not make the absence snapshot
current. Please establish an absence observation causally after the last
possible submission before releasing the barrier, and cover a delayed/retried
pre-admission report.
--
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]