[ https://issues.apache.org/jira/browse/KAFKA-4235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15534556#comment-15534556 ]
ASF GitHub Bot commented on KAFKA-4235: --------------------------------------- GitHub user becketqin opened a pull request: https://github.com/apache/kafka/pull/1939 KAFKA-4235: Fix the race condition in Sender.initiateClose() that may result in missing some callbacks. You can merge this pull request into a Git repository by running: $ git pull https://github.com/becketqin/kafka KAFKA-4235 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/1939.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1939 ---- ---- > Fix the closing order in Sender.initiateClose(). > ------------------------------------------------ > > Key: KAFKA-4235 > URL: https://issues.apache.org/jira/browse/KAFKA-4235 > Project: Kafka > Issue Type: Bug > Affects Versions: 0.10.0.0 > Reporter: Jiangjie Qin > Assignee: Jiangjie Qin > Fix For: 0.10.1.0 > > > In the initiate close, we need to call RecordAccumulator.close() before set > the running to false. Otherwise we may miss a callback if the following > sequence happens: > 1. Thread 1 call Sender.forceClose(), Sender.forceClosed is set to true, > Sender.running is set to false. > 2. Sender thread saw running == false, exited the while loop > 3. Sender thread saw the forceClose == true and aborted all the existing > incomplete batches > 4. Thread 2 append a message into the accumulator. > 5. Thread 1 closes the accumulator > 6. Sender thread exits without firing callback for the message in step (4) > To fix this, we need close the record accumulator before set the running flag > to false in the sender thread. -- This message was sent by Atlassian JIRA (v6.3.4#6332)