Skip to content

Commit

Permalink
MINOR: Logs warning message when user invoke producer#flush within ca…
Browse files Browse the repository at this point in the history
…llback (apache#18112)

Reviewers: Andrew Schofield <[email protected]>
  • Loading branch information
frankvicky authored Dec 10, 2024
1 parent b99c227 commit f57fd2d
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1219,11 +1219,19 @@ private void ensureValidRecordSize(int size) {
* flush all buffered records before performing the commit. This ensures that all the {@link #send(ProducerRecord)}
* calls made since the previous {@link #beginTransaction()} are completed before the commit.
* </p>
* <p>
* <b>Important:</b> This method should not be used within the callback provided to
* {@link #send(ProducerRecord, Callback)}. Invoking <code>flush()</code> in this context will cause a deadlock.
* </p>
*
* @throws InterruptException If the thread is interrupted while blocked
*/
@Override
public void flush() {
if (Thread.currentThread() == this.ioThread) {
log.error("KafkaProducer.flush() invocation inside a callback will cause a deadlock.");
}

log.trace("Flushing accumulated records in producer.");

long start = time.nanoseconds();
Expand Down

0 comments on commit f57fd2d

Please sign in to comment.