-
Notifications
You must be signed in to change notification settings - Fork 14.5k
KAFKA-14830: Illegal state error in transactional producer #17022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from 9 commits
7522421
26c6eae
4be2627
9cc5688
11d98a3
8f73d09
729f5dc
7d82a63
31e3a82
569467f
0567155
e2871f8
54097fa
ba1cc86
53ffde5
998787c
a8763ac
1428d80
22d04d6
da4da13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -737,14 +737,21 @@ public synchronized void maybeTransitionToErrorState(RuntimeException exception) | |
} | ||
|
||
synchronized void handleFailedBatch(ProducerBatch batch, RuntimeException exception, boolean adjustSequenceNumbers) { | ||
maybeTransitionToErrorState(exception); | ||
if (!isStaleBatch(batch) && !hasFatalError()) | ||
maybeTransitionToErrorState(exception); | ||
|
||
removeInFlightBatch(batch); | ||
|
||
if (hasFatalError()) { | ||
log.debug("Ignoring batch {} with producer id {}, epoch {}, and sequence number {} " + | ||
"since the producer is already in fatal error state", batch, batch.producerId(), | ||
batch.producerEpoch(), batch.baseSequence(), exception); | ||
return; | ||
} else if (isStaleBatch(batch)) { | ||
log.debug("Ignoring stale batch {} with producer id {}, epoch {}, and sequence number {} " + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wonder if this should be TRACE? It seems not to be important enough for DEBUG (not worried about volume, as it should only happen rarely -- just wondering about importance). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good question, @mjsax. IMO, Can we leave at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Work for me to leave a DEBUG -- was just wondering -- if it's a volume problem (what I don't expect), people could disable DEBUG for this class until we fix it. |
||
"since the producer has been re-initialized with producer id {} and epoch {}", batch, batch.producerId(), | ||
batch.producerEpoch(), batch.baseSequence(), producerIdAndEpoch.producerId, producerIdAndEpoch.epoch, exception); | ||
return; | ||
} | ||
|
||
if (exception instanceof OutOfOrderSequenceException && !isTransactional()) { | ||
|
@@ -772,6 +779,14 @@ synchronized void handleFailedBatch(ProducerBatch batch, RuntimeException except | |
} | ||
} | ||
|
||
/** | ||
* Returns {@code true} if the given {@link ProducerBatch} has the same producer ID but a different epoch than the | ||
* {@link #producerIdAndEpoch cached producer ID and epoch}. | ||
*/ | ||
synchronized boolean isStaleBatch(ProducerBatch batch) { | ||
kirktrue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return batch.producerId() == producerIdAndEpoch.producerId && batch.producerEpoch() != producerIdAndEpoch.epoch; | ||
} | ||
|
||
synchronized boolean hasInflightBatches(TopicPartition topicPartition) { | ||
return txnPartitionMap.getOrCreate(topicPartition).hasInflightBatches(); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.