lizhao created KAFKA-10899: ------------------------------ Summary: Closing check Before Producer's BufferPool allocat memory Key: KAFKA-10899 URL: https://issues.apache.org/jira/browse/KAFKA-10899 Project: Kafka Issue Type: Improvement Components: producer Affects Versions: 2.8.0 Reporter: lizhao
According to the idea of [#7967|https://github.com/apache/kafka/pull/7967], it made BufferPool support closing. Now, there are two places in the BufferPool#allocate() method to judge the 'closed' flag. One is when 'lock' is acquired, and the other is when 'condition' is awakened. However, if the memory is allocated outside the 'lock' code block after 'freeup', Therefore, it is possible for another thread to modify the 'closed' flag, causing this part of memory to be allocated in vain. So two modifications have been made, One is to add the 'volatile' modifier before 'closed', One is to determine whether to 'closed' before allocating memory. -- This message was sent by Atlassian Jira (v8.3.4#803005)