rreddy-22 opened a new pull request, #23806:
URL: https://github.com/apache/kafka/pull/23806

   Backport of #23630 to 4.1 (cherry-pick of 
9dfd65db3d5bb3297f29a4a5dea4207658511cd9).
   
   After a broker loses leadership of a `__transaction_state` partition, its 
`TransactionStateManager` keeps the partition's cache entry until 
`TransactionCoordinator.onResignation` runs, which happens after the replica 
has already become a follower. Answers decided purely from that cache are never 
fenced, so a TV2 EndTxn(COMMIT) that lands in this window can get a fatal 
`INVALID_TXN_STATE` instead of `NOT_COORDINATOR`. This only uses a cache entry 
while the local replica still leads the partition at the entry's coordinator 
epoch, and returns `NOT_COORDINATOR` otherwise so the client rediscovers the 
new coordinator.
   
   **Backport notes:** the production change is identical to trunk; only tests 
were adapted. Same `prepareForTxnMessageAppend` resolution as 4.2. The new 
tests also use Scala collections, which 4.1's `TransactionMetadata`, 
`prepareAddPartitions`, `handleVerifyPartitionsInTransaction` and 
`handleAddPartitionsToTransaction` take.
   
   **Testing:** `./gradlew :core:test --tests 'kafka.coordinator.transaction.*' 
:core:checkstyleTest` passes on 4.1, including the six new tests.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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