vamossagar12 commented on a change in pull request #9756: URL: https://github.com/apache/kafka/pull/9756#discussion_r553481214
########## File path: raft/src/main/java/org/apache/kafka/raft/internals/BatchAccumulator.java ########## @@ -211,6 +214,33 @@ public long timeUntilDrain(long currentTimeMs) { } } + /** + * Check if the current batch size has exceeded the min flush size. + * + * Note that this method works on best effort i.e it tries to acquire the append lock and if it can't + * then instead of blocking, it returns false. + * + * This means that if the thread responsible for appending is holding the lock and the linger time hasn't expired + * yet, then even though the batch size exceeds the min flush size, the records won't be drained as the lock + * couldn't be acquired. This also means that in subsequent run(s), this method should be able to acquire the lock + * and return true in the event the linger time hasn't expired yet. + * + * @return true if the append lock could be acquired and the accumulated bytes are greater than configured min flush + * bytes size, false otherwise. + */ + public boolean batchSizeExceedsMinFlushSize() { Review comment: Yeah completed batches should be considered. Also, with what you have suggested, it removes the need to hold the lock again in batchSizeExceedsMinFlushSize. Basically, we won't even need this method anymore. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org