jeel2420 commented on code in PR #14483:
URL: https://github.com/apache/kafka/pull/14483#discussion_r1348624218


##########
core/src/test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala:
##########
@@ -568,27 +621,26 @@ class RemoteIndexCacheTest {
   }
 
   private def verifyFetchIndexInvocation(count: Int,
-                                         indexTypes: Seq[IndexType] =
-                                         Seq(IndexType.OFFSET, 
IndexType.TIMESTAMP, IndexType.TRANSACTION)): Unit = {
+                                         indexTypes: Seq[IndexType]): Unit = {
     for (indexType <- indexTypes) {
       verify(rsm, 
times(count)).fetchIndex(any(classOf[RemoteLogSegmentMetadata]), 
ArgumentMatchers.eq(indexType))
     }
   }
 
   private def createTxIndexForSegmentMetadata(metadata: 
RemoteLogSegmentMetadata): TransactionIndex = {
-    val txnIdxFile = remoteTransactionIndexFile(tpDir, metadata)
+    val txnIdxFile = remoteTransactionIndexFile(new File(tpDir, DIR_NAME), 
metadata)
     txnIdxFile.createNewFile()
     new TransactionIndex(metadata.startOffset(), txnIdxFile)
   }
 
   private def createTimeIndexForSegmentMetadata(metadata: 
RemoteLogSegmentMetadata): TimeIndex = {
     val maxEntries = (metadata.endOffset() - 
metadata.startOffset()).asInstanceOf[Int]
-    new TimeIndex(remoteTimeIndexFile(tpDir, metadata), 
metadata.startOffset(), maxEntries * 12)
+    new TimeIndex(remoteTimeIndexFile(new File(tpDir, DIR_NAME), metadata), 
metadata.startOffset(), maxEntries * 12)

Review Comment:
   The reason behind storing the files in cacheDir is below.
   
   In unit test case `testConcurrentRemoveReadForCache` which reproduce the 
concurrency bug, I am first creating the index files and creating a spyEntry 
and adding it in the Cache. After calling the remove function for that spyEntry 
and before calling the markForCleanup(), when I am calling getIndexEntry 
without the above change (i.e creating the files in tpDir), in loadIndexFile() 
it is trying to fetch the index from remote again which I don't think is right 
as spyEntry is not yet renamed and it should be picked from the file.
   
   Also, once the markForCleanup() called, the index files are getting renamed 
into tpDir only if we create the index files in tpDir and actual index files 
are getting stored in cacheDir so that way it is not possible to reproduce this 
bug.



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