chia7712 commented on code in PR #19972:
URL: https://github.com/apache/kafka/pull/19972#discussion_r2158692715


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogSegment.java:
##########
@@ -192,8 +192,13 @@ public void sanityCheck(boolean timeIndexFileNewlyCreated) 
throws IOException {
      * the time index).
      */
     public TimestampOffset readMaxTimestampAndOffsetSoFar() throws IOException 
{
-        if (maxTimestampAndOffsetSoFar == TimestampOffset.UNKNOWN)

Review Comment:
   > memory map for all segments will be created eagerly at startup
   
   You're right. 
   
   The lock approach works for me, but maybe there's another approach that 
doesn't need a lock. We can pre-load the `maxTimestampAndOffsetSoFar` at 
startup for the active segment. If I understand this issue correctly, the issue 
happens only in the active segment. Fortunately, the memory map of the active 
segment is always pre-loaded. Hence, we can initialize the 
`maxTimestampAndOffsetSoFar` at the same time. WDYT?
   



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