You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "squah-confluent (via GitHub)" <gi...@apache.org> on 2026/10/22 18:06:31 UTC
[PR] KAFKA-21312: Revert CoordinatorExecutor tasks scheduled by failed writes [kafka]
squah-confluent opened a new pull request, #23923:
URL: https://github.com/apache/kafka/pull/23923
When a write fails, the runtime reverts the coordinator state, but not
the tasks scheduled by the reverted write operations. When those tasks
complete, their results may no longer apply to the coordinator state.
Have the executor take part in the coordinator state's snapshots.
Reverting to a snapshot now also cancels the tasks scheduled since that
snapshot. Tasks cancelled or completed since the snapshot are not
restored. It is expected that callers re-schedule them if they are
still needed.
Do the same in MockCoordinatorExecutor and
GroupMetadataManagerTestContext, for use in future tests that roll back
writes which schedule tasks.
Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-21312: Implement snapshottable tasks in the coordinator runtime [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #23923:
URL: https://github.com/apache/kafka/pull/23923#discussion_r4352497676
##########
coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorExecutorImpl.java:
##########
@@ -176,6 +178,12 @@ synchronized boolean isReleased() {
private final CoordinatorShardScheduler<U> scheduler;
private final Map<String, Task<?>> tasks = new ConcurrentHashMap<>();
+ /**
+ * The keys of the tasks scheduled since the last snapshot taken by {@link #createSnapshot()}.
+ * These tasks are cancelled when reverting to the snapshot with {@link #revertToSnapshot()}.
+ */
+ private final Set<String> tasksToCancelOnRevert = new HashSet<>();
Review Comment:
Have you considered the other way around? We could keep the new tasks as pending until the write succeeds. The benefit is that it would only use the executor when it is really decided.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-21312: Implement snapshottable tasks in the coordinator runtime [kafka]
Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on code in PR #23923:
URL: https://github.com/apache/kafka/pull/23923#discussion_r4369998732
##########
coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorExecutorImpl.java:
##########
@@ -232,6 +245,39 @@ public void cancelAll() {
tasks.keySet().forEach(this::cancel);
}
+ /**
+ * Submits the tasks scheduled by the operations in the current batch, now that the batch
+ * has been written.
+ */
+ public void onBatchWritten() {
Review Comment:
How do we ensure that the tasks in currentBatchTasks belong to the batch being flushed?
An operation may schedule a task while generating its records, before `append()` is called. If `append()` then needs to flush the previous batc--for example, because the new records do not fit--could `onBatchWritten()` submit that task before its own records have been appended?
If the subsequent append fails, the task may already have been submitted even though the records it depends on were not written. Is there a guarantee that prevents this sequence, or do we need to associate the tasks more explicitly with their batch?
(I'm struggling with this in KAFKA-19023 as well. 😓 )
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-21312: Implement snapshottable tasks in the coordinator runtime [kafka]
Posted by "squah-confluent (via GitHub)" <gi...@apache.org>.
squah-confluent commented on code in PR #23923:
URL: https://github.com/apache/kafka/pull/23923#discussion_r4359324839
##########
coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorExecutorImpl.java:
##########
@@ -176,6 +178,12 @@ synchronized boolean isReleased() {
private final CoordinatorShardScheduler<U> scheduler;
private final Map<String, Task<?>> tasks = new ConcurrentHashMap<>();
+ /**
+ * The keys of the tasks scheduled since the last snapshot taken by {@link #createSnapshot()}.
+ * These tasks are cancelled when reverting to the snapshot with {@link #revertToSnapshot()}.
+ */
+ private final Set<String> tasksToCancelOnRevert = new HashSet<>();
Review Comment:
That would be good for saving resources in the (less common) cases where reverts happen. We don't have any strong latency requirements for the tasks so it sounds okay. I tried it in the latest update to the PR. It's a little more complicated to test now that it's part of the task lifecycle.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-21312: Implement snapshottable tasks in the coordinator runtime [kafka]
Posted by "squah-confluent (via GitHub)" <gi...@apache.org>.
squah-confluent commented on code in PR #23923:
URL: https://github.com/apache/kafka/pull/23923#discussion_r4371941197
##########
coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorExecutorImpl.java:
##########
@@ -232,6 +245,39 @@ public void cancelAll() {
tasks.keySet().forEach(this::cancel);
}
+ /**
+ * Submits the tasks scheduled by the operations in the current batch, now that the batch
+ * has been written.
+ */
+ public void onBatchWritten() {
Review Comment:
You've stumbled upon one of the bugs in https://issues.apache.org/jira/browse/KAFKA-20912. It also impacts non-replaying operations which update the timeline structures directly.
We haven't decided how to fix it yet. One option could be to drop the flush-on-large-batch entirely. Another could be to create a snapshot after each append().
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org