jolshan commented on code in PR #23630:
URL: https://github.com/apache/kafka/pull/23630#discussion_r4201429089
##########
core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:
##########
@@ -391,6 +391,14 @@ class TransactionStateManager(brokerId: Int,
})
}
+ /**
+ * Check whether this broker still leads the given transaction state
partition at the given coordinator epoch.
+ * The cache entry is only removed on resignation, which happens after the
replica becomes a follower.
+ */
+ private def isCoordinatorFor(partitionId: Int, coordinatorEpoch: Int):
Boolean =
+ replicaManager.onlinePartition(new
TopicPartition(Topic.TRANSACTION_STATE_TOPIC_NAME, partitionId))
Review Comment:
I see the trade-offs of having one solution (allow empty commit) could be
better than adding multiple places to fail. However, one benefit to your fix is
we don't write anything in the log at all. (We have seen some issues when
truncation didn't happen properly). I don't feel super strongly either way.
I think my only concern is we are removing a check for a faulty client (ie
-- we should never commit an empty transaction from the client perspective) and
we are making this change to cover for this race condition -- we don't actually
intend to allow empty commits. Still I suppose we will want to do that anyway
to cover the slow metadata case and we will handle truncation elsewhere.
TLDR; I can see benefits for doing both fixes, but don't feel strongly about
merging both vs just doing the empty commit. If Artem doesn't feel strongly, I
can merge this.
--
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]