junrao commented on code in PR #19961:
URL: https://github.com/apache/kafka/pull/19961#discussion_r2167615152


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/OffsetIndex.java:
##########
@@ -95,7 +99,7 @@ public void sanityCheck() {
      *         the pair (baseOffset, 0) is returned.
      */
     public OffsetPosition lookup(long targetOffset) {
-        return maybeLock(lock, () -> {
+        return inLock(lock, () -> {

Review Comment:
   @Forest0923 : Good question. It's true that happens-before guarantee is not 
guaranteed according to javadoc. However, according to 
[this](https://stackoverflow.com/questions/7002510/can-multiple-threads-see-writes-on-a-direct-mapped-bytebuffer-in-java),
 MappedByteBuffer is a thin wrapper and provides direct access to buffer cache 
of the OS. So, once you have written to it, every thread, and every process, 
will see the update. In addition to the index file, we read from the buffer 
cache for the log file without synchronization too. The implementation may 
change in the future, but probably unlikely.
   
   So for now, it's probably better to use a separate resize lock to maintain 
the current read/write concurrency?



-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to