Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client.EndTransaction: if offsets were added to transaction, ensure w…
…e commit First, this fixes setting offsetsAddedToTxn to true. That was never done, which inadvertently would have called AddOffsetsToTxn more than we needed to if we did not only call it in Session.End. If a client consumes within a transaction but does not produce, when we end the transaction, before this commit we actually avoided sending an EndTxn request. This was because no partition was produced to. As it turns out, because we consumed, we issue AddOffsetsToTxn. Internally within Kafka, this adds the __consumer_offsets partition responsible for this group to the transaction itself, and this falls into AddPartitionsToTxn, which itself is the logic that actually begins a transaction. So, if we consume at all, we need to commit so that we properly end the transaction. If we do not, we leave the transaction open, and potentially if we are low volume enough, later time out. Finally, because AddOffsetsToTxn can trigger the start of a transaction, we also need to handle the CONCURRENT_TRANSACTIONS error that can crop up if we start a transaction too quickly after finishing the old. This was already handled in sink.go, so this copies the code straight from that and changes a few logging statements.
- Loading branch information