-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-7672: Restoring tasks need to be closed upon task suspension #6113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f8e418c
cd7ec98
3734744
178bcc3
6832e3f
4429819
912a456
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -277,6 +277,7 @@ public void reset() { | |
| needsRestoring.clear(); | ||
| endOffsets.clear(); | ||
| needsInitializing.clear(); | ||
| completedRestorers.clear(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is @linyli001 's fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added some hack code to listeners and transformer init func before next version release.. |
||
| } | ||
|
|
||
| private long processNext(final List<ConsumerRecord<byte[], byte[]>> records, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,11 +99,11 @@ void createTasks(final Collection<TopicPartition> assignment) { | |
| throw new IllegalStateException(logPrefix + "consumer has not been initialized while adding stream tasks. This should not happen."); | ||
| } | ||
|
|
||
| changelogReader.reset(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not reset changelogReader since we still need its restored offset when closing the restoring tasks. |
||
| // do this first as we may have suspended standby tasks that | ||
| // will become active or vice versa | ||
| standby.closeNonAssignedSuspendedTasks(assignedStandbyTasks); | ||
| active.closeNonAssignedSuspendedTasks(assignedActiveTasks); | ||
|
|
||
| addStreamTasks(assignment); | ||
| addStandbyTasks(); | ||
| // Pause all the partitions until the underlying state store is ready for all the active tasks. | ||
|
|
@@ -240,7 +240,14 @@ void suspendTasksAndState() { | |
| final AtomicReference<RuntimeException> firstException = new AtomicReference<>(null); | ||
|
|
||
| firstException.compareAndSet(null, active.suspend()); | ||
| // close all restoring tasks as well and then reset changelog reader; | ||
| // for those restoring and still assigned tasks, they will be re-created | ||
| // in addStreamTasks. | ||
| firstException.compareAndSet(null, active.closeAllRestoringTasks()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we close those tasks instead of just suspending them? Could we close them only if they are not re-assigned?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The life time of a task is: created -> [initializeStateStores] -> restoring (writes to the initialized state stores) -> [initializeTopology] -> running -> [closeTopology] -> suspended -> [closeStateManager] -> dead I.e. the restoring tasks do not have topology initialized at all, whereas
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but why can't we keep restoring task open than, and hope they get reassigned so we can continue restoring them?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we can, the issue is that today we clear all the We can, of course do some optimizations like cc @vvcephei
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @guozhangwang Can you create a Jira to track this cleanup?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| changelogReader.reset(); | ||
|
|
||
| firstException.compareAndSet(null, standby.suspend()); | ||
|
|
||
| // remove the changelog partitions from restore consumer | ||
| restoreConsumer.unsubscribe(); | ||
|
|
||
|
|
@@ -368,7 +375,7 @@ public void setPartitionsByHostState(final Map<HostInfo, Set<TopicPartition>> pa | |
| } | ||
|
|
||
| public void setAssignmentMetadata(final Map<TaskId, Set<TopicPartition>> activeTasks, | ||
| final Map<TaskId, Set<TopicPartition>> standbyTasks) { | ||
| final Map<TaskId, Set<TopicPartition>> standbyTasks) { | ||
| this.assignedActiveTasks = activeTasks; | ||
| this.assignedStandbyTasks = standbyTasks; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following three functions do not have logical changes, just re-grouping all overridden functions on top of AssignedTasks here.