You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "frankvicky (via GitHub)" <gi...@apache.org> on 2024/12/10 00:38:31 UTC

[PR] MINOR: Logs warning message when user invoke producer#flush within callback [kafka]

frankvicky opened a new pull request, #18112:
URL: https://github.com/apache/kafka/pull/18112

   As title.
   Please refer to the discussion of #17946 for further details
   
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Logs warning message when user invoke producer#flush within callback [kafka]

Posted by "AndrewJSchofield (via GitHub)" <gi...@apache.org>.
AndrewJSchofield merged PR #18112:
URL: https://github.com/apache/kafka/pull/18112


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Logs warning message when user invoke producer#flush within callback [kafka]

Posted by "frankvicky (via GitHub)" <gi...@apache.org>.
frankvicky commented on code in PR #18112:
URL: https://github.com/apache/kafka/pull/18112#discussion_r1877691904


##########
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:
##########
@@ -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.

Review Comment:
   Thanks for pointing out 😺 



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Logs warning message when user invoke producer#flush within callback [kafka]

Posted by "AndrewJSchofield (via GitHub)" <gi...@apache.org>.
AndrewJSchofield commented on code in PR #18112:
URL: https://github.com/apache/kafka/pull/18112#discussion_r1877681402


##########
clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java:
##########
@@ -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.

Review Comment:
   nit: Space before "Invoking" please.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Logs warning message when user invoke producer#flush within callback [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #18112:
URL: https://github.com/apache/kafka/pull/18112#discussion_r1877395191


##########
docs/upgrade.html:
##########
@@ -159,6 +159,9 @@ <h5><a id="upgrade_400_notable" href="#upgrade_400_notable">Notable changes in 4
                         </li>
                         <li>The deprecated <code>sendOffsetsToTransaction(Map&lt;TopicPartition, OffsetAndMetadata&gt;, String)</code> method has been removed from the Producer API.
                         </li>
+                        <li>The <code>flush</code> method now detects potential deadlocks and logs a warning when used inside a callback.

Review Comment:
   this is unnecessary as it is just a log.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Logs warning message when user invoke producer#flush within callback [kafka]

Posted by "AndrewJSchofield (via GitHub)" <gi...@apache.org>.
AndrewJSchofield commented on code in PR #18112:
URL: https://github.com/apache/kafka/pull/18112#discussion_r1877686289


##########
docs/upgrade.html:
##########
@@ -159,6 +159,9 @@ <h5><a id="upgrade_400_notable" href="#upgrade_400_notable">Notable changes in 4
                         </li>
                         <li>The deprecated <code>sendOffsetsToTransaction(Map&lt;TopicPartition, OffsetAndMetadata&gt;, String)</code> method has been removed from the Producer API.
                         </li>
+                        <li>The <code>flush</code> method now detects potential deadlocks and logs a warning when used inside a callback.

Review Comment:
   Personally, I tend the other way on this. If someone is now getting errors logged, this explains why. No big deal either way, I suppose. Just my 2 cents.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org