lucasbru commented on code in PR #22864:
URL: https://github.com/apache/kafka/pull/22864#discussion_r4524304227
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:
##########
@@ -494,7 +503,7 @@ public Map<TopicPartition, Long>
logicalChangelogEndOffsets() {
public long restore(final Map<TaskId, Task> tasks) {
initializeChangelogs(tasks, registeredChangelogs());
- if (!activeRestoringChangelogs().isEmpty() && state ==
ChangelogReaderState.STANDBY_UPDATING) {
+ if (!activeRestoringChangelogs(tasks).isEmpty() && state ==
ChangelogReaderState.STANDBY_UPDATING) {
throw new IllegalStateException("Should not be in standby updating
state if there are still un-completed active changelogs");
Review Comment:
nit: the guard now only looks at active changelogs of updating tasks, but
the message still says "un-completed active changelogs". Maybe "...of updating
tasks", so nobody reads it as "no active changelog may be restoring in standby
mode" (paused tasks' changelogs legitimately are).
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:
##########
@@ -448,6 +448,15 @@ private Set<TopicPartition> activeRestoringChangelogs() {
.collect(Collectors.toSet());
}
+ private Set<TopicPartition> activeRestoringChangelogs(final Map<TaskId,
Task> tasks) {
Review Comment:
nit: this overload and the no-arg `activeRestoringChangelogs()` have the
same name but different meaning (only updating tasks vs. all). The guard needs
the filtered one, and the `pause` below needs the unfiltered one, so mixing
them up reintroduces the crash or stops pausing paused tasks' changelogs. A
different name (e.g. `activeRestoringChangelogsOf(tasks)`) would make that
visible at the call sites.
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:
##########
@@ -574,9 +583,9 @@ private void pauseResumePartitions(final Map<TaskId, Task>
tasks,
final Set<TopicPartition>
restoringChangelogs) {
if (state == ChangelogReaderState.ACTIVE_RESTORING) {
updatePartitionsByType(tasks, restoringChangelogs,
TaskType.ACTIVE);
- }
- if (state == ChangelogReaderState.STANDBY_UPDATING) {
+ } else {
updatePartitionsByType(tasks, restoringChangelogs,
TaskType.STANDBY);
+ restoreConsumer.pause(activeRestoringChangelogs());
Review Comment:
nit: this runs on every `restore()` iteration in standby mode, building the
set and calling `pause` even when there is no active changelog restoring, which
is the common case. Cheap, but we could skip it when the set is empty.
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/StoreChangelogReaderTest.java:
##########
@@ -1482,6 +1482,34 @@ public void shouldTransitState() {
assertEquals(Set.of(tp1, tp2), consumer.paused());
}
+ @Test
+ public void shouldPauseRestoringActiveChangelogsWhenUpdatingStandbyTasks()
{
Review Comment:
This test does not check the way back: with the `resume` call in
`updatePartitionsByType` removed, all tests in `StoreChangelogReaderTest` and
`DefaultStateUpdaterTest` still pass. Could we extend it with
`enforceRestoreActive()` + `restore()` with both tasks and assert that the
active changelog is resumed again (paused == only the standby changelog), and
that `restore()` with both tasks in standby mode still throws?
--
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]