[ https://issues.apache.org/jira/browse/KAFKA-12233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17271125#comment-17271125 ]
dengziming commented on KAFKA-12233: ------------------------------------ [~chia7712] Thank you, I inspected it again, and below is my understanding. # FileRecords.writeTo is called my `RecordSend` and the method signature is `writeTo(TransferableChannel channel, long previouslyWritten, int remaining)` # We assume the log file isn't truncated (oldSize=sizeInBytes), so we set length=(min(remaining, sizeInBytes)), but remaining < sizeInBytes is always true # So the real size should be (min(remaining, sizeInBytes - previouslyWritten)), (sizeInBytes - previouslyWritten) represents remaining size to be written. Also ping [~hachikuji] to have a look, he set `count = min(length, size - offset)` in KAFKA-2066 [https://github.com/apache/kafka/pull/2069] , but he overwrite `count=min(length, size)` in KAFKA-4390 [https://github.com/apache/kafka/pull/2140] , I think the previous is more reasonable. > `FileRecords.writeTo` set length incorrectly > -------------------------------------------- > > Key: KAFKA-12233 > URL: https://issues.apache.org/jira/browse/KAFKA-12233 > Project: Kafka > Issue Type: Bug > Reporter: dengziming > Assignee: dengziming > Priority: Major > > [https://github.com/apache/kafka/pull/2140/files#r563471404] > we set `int count = Math.min(length, oldSize)`, but we are expected to write > from `offset`, so the count should be `Math.min(length, oldSize - offset)`. -- This message was sent by Atlassian Jira (v8.3.4#803005)