Lucas Brutschy created KAFKA-21699:
--------------------------------------

             Summary: Streams group: after a coordinator load, the re-derived 
intermediate assignment can leave an active task unassigned for the rest of the 
epoch
                 Key: KAFKA-21699
                 URL: https://issues.apache.org/jira/browse/KAFKA-21699
             Project: Kafka
          Issue Type: Bug
          Components: group-coordinator
            Reporter: Lucas Brutschy


With warm-up tasks enabled ({{group.streams.num.warmup.replicas}} > 0), 
{{GroupMetadataManager#refinedAssignmentForEpoch}} derives the intermediate 
assignment of an assignment epoch once and caches it in memory. The cache is 
lost when a new coordinator loads the group. For an epoch from before the load, 
the intermediate assignment is derived again with {{keepActiveTasks = true}}, 
so every active task that a member holds stays with it.

An active task that no member holds is still placed as usual. The refiner may 
stage it on another member, e.g. by promoting a standby task of the task on a 
member that does not report its restore progress 
({{AssignmentRefinerImpl#unobservableStandbyToPromote}}). If that member 
already reconciled to the epoch before the load, it is STABLE at the epoch, and 
{{CurrentAssignmentBuilder}} does not reconcile it again until the next epoch. 
The target owner does not get the task either, so no member processes it until 
the group epoch is bumped for another reason.

h3. Steps to reproduce (unit level)
# Streams group at epoch 12 with a stateful subtopology. Target assignment: 
member A active 0_0 and 0_1 with standby 0_2, member B active 0_2. A is STABLE 
at epoch 12 and holds 0_0, 0_1 and standby 0_2. B is at epoch 11 and holds 
nothing. No member holds 0_2 as an active task, e.g. because the member that 
ran it left.
# Load the group ({{onLoaded}}), so the intermediate assignment of epoch 12 is 
not cached.
# B heartbeats at epoch 11. The re-derived intermediate assignment promotes A's 
standby task 0_2 to active. A is not reconciled again within epoch 12, and B 
reconciles to epoch 12 without 0_2.

h3. Impact
The input partitions of the task are not processed, without an error, until the 
next epoch: usually the next membership or metadata change. The window opens 
with a failover in the middle of an epoch with warm-up tasks.

h3. Possible fix
After deriving the intermediate assignment of an epoch from before the load, 
move every active task that no member holds off the members that are STABLE at 
the epoch: to its target owner if that member did not reconcile to the epoch 
yet, and otherwise to another member that did not. The member that the lost 
intermediate assignment gave the task to has not reconciled to the epoch, since 
it would otherwise hold the task, so such a member exists. A prototype of this 
fix exists (with a unit test along the steps above).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to