[ https://issues.apache.org/jira/browse/KAFKA-9156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16984377#comment-16984377 ]
ASF GitHub Bot commented on KAFKA-9156: --------------------------------------- alexandrfox commented on pull request #7760: KAFKA-9156: fix LazyTimeIndex & LazyOffsetIndex concurrency URL: https://github.com/apache/kafka/pull/7760 Fix of https://issues.apache.org/jira/browse/KAFKA-9156 Race condition in `get` method of `LazyTimeIndex` and `LazyOffsetIndex` can lead to multiple OffsetIndex/TimeIndex objects being concurrently created. When that happens position of `MappedByteBuffer` in `AbstractIndex` is advanced to the last entry which in turn leads to a critical `BufferOverflowException` being thrown whenever leader or replica tries to append a record to the segment. Moreover, `file_=` setter is seemingly also vulnerable to the race, since multiple threads can attempt to set a new file reference as well as create new Time/OffsetIndex objects at the same time. This might lead to the discrepant File references being held by e.g. LazyTimeIndex and its TimeIndex counterpart. ### 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > LazyTimeIndex & LazyOffsetIndex may cause niobufferoverflow in concurrent > state > ------------------------------------------------------------------------------- > > Key: KAFKA-9156 > URL: https://issues.apache.org/jira/browse/KAFKA-9156 > Project: Kafka > Issue Type: Bug > Components: core > Affects Versions: 2.3.0 > Reporter: shilin Lu > Priority: Critical > Attachments: image-2019-11-07-17-42-13-852.png, > image-2019-11-07-17-44-05-357.png, image-2019-11-07-17-46-53-650.png > > > !image-2019-11-07-17-42-13-852.png! > this timeindex get function is not thread safe ,may cause create some > timeindex. > !image-2019-11-07-17-44-05-357.png! > When create timeindex not exactly one ,may cause mappedbytebuffer position to > end. Then write index entry to this mmap file will cause > java.nio.BufferOverflowException. > > !image-2019-11-07-17-46-53-650.png! > > > -- This message was sent by Atlassian Jira (v8.3.4#803005)