arnabnandy7 opened a new pull request, #22864:
URL: https://github.com/apache/kafka/pull/22864

   Fixes KAFKA-20731.
   
   `DefaultStateUpdater` could call the non-idempotent 
`ChangelogReader#transitToUpdateStandby` method while the changelog reader was 
already in `STANDBY_UPDATING`. This could happen after all updating standby 
tasks were paused or removed because the empty-task state did not transition 
the reader back to `ACTIVE_RESTORING`. Adding or resuming a standby task 
afterward attempted the standby transition again, throwing an 
`IllegalStateException` and terminating the state updater thread.
   
   This change centralizes changelog reader state transitions in 
`DefaultStateUpdater` and enforces the following invariants:
   
   - When there are no updating tasks, the reader is in `ACTIVE_RESTORING`.
   - When only standby tasks are updating, the reader transitions to 
`STANDBY_UPDATING` only if it is currently restoring active tasks.
   - The existing non-idempotent contract and defensive exception in 
`StoreChangelogReader#transitToUpdateStandby` remain unchanged.
   
   The transition helper is invoked after task additions, resumptions, pauses, 
removals, failures, and active restoration completion so that the reader state 
remains consistent with the updating task set.
   
   The `DefaultStateUpdaterTest` changelog reader mock now models the actual 
reader state transitions. This allows the standby pause/resume regression test 
to fail if `transitToUpdateStandby` is invoked twice without an intervening 
transition back to active restoration.
   
   Testing:
   
   ```
   gradle streams:test \
     --tests 
org.apache.kafka.streams.processor.internals.DefaultStateUpdaterTest \
     --no-daemon \
     --console=plain
   ```
   
   All 87 `DefaultStateUpdaterTest` tests passed. The test execution also 
completed `checkstyleMain`, `checkstyleTest`, and `spotbugsMain` successfully.


-- 
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]

Reply via email to