You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "abhijeetk88 (via GitHub)" <gi...@apache.org> on 2023/09/09 14:09:24 UTC

[GitHub] [kafka] abhijeetk88 opened a new pull request, #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

abhijeetk88 opened a new pull request, #14363:
URL: https://github.com/apache/kafka/pull/14363

   
   *More detailed description of your change,
   if necessary. The PR title and PR message become
   the squashed commit message, so use a separate
   comment to ping reviewers.*
   
   *Summary of testing strategy (including rationale)
   for the feature or bug fix. Unit and/or integration
   tests are expected for any behaviour change and
   system tests should be considered for larger changes.*
   
   ### 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.

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

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


[GitHub] [kafka] divijvaidya commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1321639606


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -523,7 +533,9 @@ public void markForCleanup() throws IOException {
                     markedForCleanup = true;
                     offsetIndex.renameTo(new File(Utils.replaceSuffix(offsetIndex.file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
                     timeIndex.renameTo(new File(Utils.replaceSuffix(timeIndex.file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
-                    txnIndex.renameTo(new File(Utils.replaceSuffix(txnIndex.file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
+                    if (txnIndexOpt.isPresent()) {
+                        txnIndexOpt.get().renameTo(new File(Utils.replaceSuffix(txnIndexOpt.get().file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
+                    }

Review Comment:
   sure.



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] showuon commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1320955941


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -382,6 +385,8 @@ private RemoteIndexCache.Entry createCacheEntry(RemoteLogSegmentMetadata remoteL
             TransactionIndex txnIndex = loadIndexFile(txnIndexFile, remoteLogSegmentMetadata, rlsMetadata -> {
                 try {
                     return remoteStorageManager.fetchIndex(rlsMetadata, IndexType.TRANSACTION);
+                } catch (RemoteResourceNotFoundException e) {
+                    return null;

Review Comment:
   We'd better to add some comment here to explain why we treat txnIndex differently. Ex:
   `Don't throw exception since the transaction index may not exist because of no transactional records.`
   



##########
storage/api/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteStorageManager.java:
##########
@@ -123,7 +123,7 @@ InputStream fetchLogSegment(RemoteLogSegmentMetadata remoteLogSegmentMetadata,
      * Returns the index for the respective log segment of {@link RemoteLogSegmentMetadata}.
      * <p>
      * Note: The transaction index may not exist because of no transactional records.

Review Comment:
   Good to me, too.



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -451,7 +456,7 @@ public static class Entry implements AutoCloseable {
 
         private final OffsetIndex offsetIndex;
         private final TimeIndex timeIndex;
-        private final TransactionIndex txnIndex;
+        private final Optional<TransactionIndex> txnIndexOpt;

Review Comment:
   We should make it clear again why we treat txnIndex differently. Please add a comment. Thanks.



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] abhijeetk88 commented on pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "abhijeetk88 (via GitHub)" <gi...@apache.org>.
abhijeetk88 commented on PR #14363:
URL: https://github.com/apache/kafka/pull/14363#issuecomment-1713178199

   @showuon Thanks for review. I have addressed your comments. Please take a look.


-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] showuon commented on pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on PR #14363:
URL: https://github.com/apache/kafka/pull/14363#issuecomment-1713815562

   > Since, trxIndex is optional, for most cases, this will end up deleting these pre-existing index files and loading them again from remote. This is the safe way because we don't know if the trxIndex is genuinely missing because it doesn't exist for this segment or it's missing due to some error.
   
   > May I suggest that we use an empty file on disk to specify that trxIndex is genuinely absent (and not because of some error)? This would help make the interface more deterministic since now we can differentiate cases genuine vs. error scenario.
   
   Nice catch! Yes, this is indeed an issue. For your suggestion @divijvaidya , I was thinking about how we could distinguish between "real empty txnInex file" and the one with absent txnIndex file. Then, I realize we don't have to care about that because in both cases, we basically will do no-op when getting the file. So, I'm +1 to store an empty txnIndex file instead of `null` in the cache entry.


-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] abhijeetk88 commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "abhijeetk88 (via GitHub)" <gi...@apache.org>.
abhijeetk88 commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1320682506


##########
core/src/test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala:
##########
@@ -143,6 +143,28 @@ class RemoteIndexCacheTest {
     verifyNoInteractions(rsm)
   }
 
+  @Test
+  def testFetchIndexForMissingTransactionIndex(): Unit = {
+    when(rsm.fetchIndex(any(classOf[RemoteLogSegmentMetadata]), any(classOf[IndexType])))

Review Comment:
   In this test, I am trying to verify that if the actual implementation throws the `RemoteResourceNotFoundException`, it is handled correctly by the `createCacheEntry` method.



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] kamalcph commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1321200355


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -573,8 +587,7 @@ public String toString() {
             return "Entry{" +
                     "offsetIndex=" + offsetIndex.file().getName() +
                     ", timeIndex=" + timeIndex.file().getName() +
-                    ", txnIndex=" + txnIndex.file().getName() +
-                    '}';
+                    ", txnIndex=" + txnIndexOpt.map(index -> index.file().getName()) + '}';

Review Comment:
   Won't this throw NPE?



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] ivanyu commented on pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "ivanyu (via GitHub)" <gi...@apache.org>.
ivanyu commented on PR #14363:
URL: https://github.com/apache/kafka/pull/14363#issuecomment-1713147646

   Thank you @abhijeetk88!
   Apart from what's requested by @showuon, LGTM


-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] satishd commented on pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on PR #14363:
URL: https://github.com/apache/kafka/pull/14363#issuecomment-1713713667

   @divijvaidya I do not have a strong opinion on that, I am fine with either way. Sure, we can create an empty file in the file cache if there is no txnIndex for a specific segment.


-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] abhijeetk88 commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "abhijeetk88 (via GitHub)" <gi...@apache.org>.
abhijeetk88 commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1321437948


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -523,7 +533,9 @@ public void markForCleanup() throws IOException {
                     markedForCleanup = true;
                     offsetIndex.renameTo(new File(Utils.replaceSuffix(offsetIndex.file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
                     timeIndex.renameTo(new File(Utils.replaceSuffix(timeIndex.file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
-                    txnIndex.renameTo(new File(Utils.replaceSuffix(txnIndex.file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
+                    if (txnIndexOpt.isPresent()) {
+                        txnIndexOpt.get().renameTo(new File(Utils.replaceSuffix(txnIndexOpt.get().file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
+                    }

Review Comment:
   I wanted to avoid doing this because the `renameTo` method throws IOException and then we have to do it something like this, which looks ugly.
   
   ```
     txnIndexOpt.ifPresent(transactionIndex -> {
         try {
             transactionIndex.renameTo(new File(Utils.replaceSuffix(transactionIndex.file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
     });
   ```



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -545,7 +557,9 @@ public void cleanup() throws IOException {
                         timeIndex.deleteIfExists();
                         return null;
                     }, () -> {
-                        txnIndex.deleteIfExists();
+                        if (txnIndexOpt.isPresent()) {
+                            txnIndexOpt.get().deleteIfExists();
+                        }

Review Comment:
   Same here. It would become something like this.
   ```
     txnIndexOpt.ifPresent(transactionIndex -> {
         try {
             transactionIndex.deleteIfExists();
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
     });
   ```



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -573,8 +587,7 @@ public String toString() {
             return "Entry{" +
                     "offsetIndex=" + offsetIndex.file().getName() +
                     ", timeIndex=" + timeIndex.file().getName() +
-                    ", txnIndex=" + txnIndex.file().getName() +
-                    '}';
+                    ", txnIndex=" + txnIndexOpt.map(index -> index.file().getName()) + '}';

Review Comment:
   If the index is present, it prints something like "Optional[filename]". I think printing "Optional.empty", when empty is in line with the non-empty case and I would prefer it this way.



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -382,6 +388,9 @@ private RemoteIndexCache.Entry createCacheEntry(RemoteLogSegmentMetadata remoteL
             TransactionIndex txnIndex = loadIndexFile(txnIndexFile, remoteLogSegmentMetadata, rlsMetadata -> {
                 try {
                     return remoteStorageManager.fetchIndex(rlsMetadata, IndexType.TRANSACTION);
+                } catch (RemoteResourceNotFoundException e) {
+                    // Don't throw an exception since the transaction index may not exist because of no transactional records.
+                    return null;

Review Comment:
   Do you mean we should add javadoc to the below method? This one is the caller and the second parameter could receive null input stream. 
   
   ```
       private <T> T loadIndexFile(File file, RemoteLogSegmentMetadata remoteLogSegmentMetadata,
                                   Function<RemoteLogSegmentMetadata, InputStream> fetchRemoteIndex,
                                   Function<File, T> readIndex) throws IOException {
   ```
   The method is private. Should we still add a javadoc?



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] satishd merged pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd merged PR #14363:
URL: https://github.com/apache/kafka/pull/14363


-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] divijvaidya commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1321639087


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -573,8 +587,7 @@ public String toString() {
             return "Entry{" +
                     "offsetIndex=" + offsetIndex.file().getName() +
                     ", timeIndex=" + timeIndex.file().getName() +
-                    ", txnIndex=" + txnIndex.file().getName() +
-                    '}';
+                    ", txnIndex=" + txnIndexOpt.map(index -> index.file().getName()) + '}';

Review Comment:
   sure.



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] Lalolokos1 commented on pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "Lalolokos1 (via GitHub)" <gi...@apache.org>.
Lalolokos1 commented on PR #14363:
URL: https://github.com/apache/kafka/pull/14363#issuecomment-1712703332

   > In this PR, we have updated the RSM's fetchIndex to throw a ResourceNotFoundException if it does not have TransactionIndex. Currently, it expects an empty InputStream and creates an unnecessary file in the cache. 
   > We now catch the exception and do not create unnecessary files.
   > 
   > Also, updated the LocalTieredStorage implementation to adhere to the new contract.
   > 
   > Added Unit Tests for the change.
   > 
   > ### Committer Checklist (excluded from commit message)
   > - [ ] Verify design and implementation 
   > - [ ] Verify test coverage and CI build status
   > - [ ] Verify documentation (including upgrade notes)
   > 
   
   jerardoaguinigacervantes6@gmail.com  jerardoaguinigacervantes6@gmail.com
   Lalolokos
   Laylow
   Highly recommend it
   To login information update on Management major owner ceo dev team group chat - [ ] # # Google meets phone Data https and YOUTUBE APP FOR THE WORLD TO LOGIN INFORMATION UPDATE ON THERE OWN EMAIL 


-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] satishd commented on pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on PR #14363:
URL: https://github.com/apache/kafka/pull/14363#issuecomment-1713712242

   @divijvaidya  I do not have a strong opinion on that, I am fine with either way. We can create an empty file like earlier in the file cache if there is no txnIndex for a specific segment.  


-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] satishd commented on pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on PR #14363:
URL: https://github.com/apache/kafka/pull/14363#issuecomment-1715619263

   There are unrelated test failures, merging it to trunk and 3.6.


-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] satishd commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1320684687


##########
storage/api/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteStorageManager.java:
##########
@@ -123,7 +123,7 @@ InputStream fetchLogSegment(RemoteLogSegmentMetadata remoteLogSegmentMetadata,
      * Returns the index for the respective log segment of {@link RemoteLogSegmentMetadata}.
      * <p>
      * Note: The transaction index may not exist because of no transactional records.

Review Comment:
   I am fine to leave this comment for better clarity even though [param doc](https://github.com/apache/kafka/pull/14363/files#diff-39904d4df047525df5309abf04c33a73e7ecb74e175d81729bc17ffd7c7067bdR132) clarifies that `RemoteResourceNotFoundException` is thrown when any index is not found in remote storage. 



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] divijvaidya commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1321327137


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -523,7 +533,9 @@ public void markForCleanup() throws IOException {
                     markedForCleanup = true;
                     offsetIndex.renameTo(new File(Utils.replaceSuffix(offsetIndex.file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
                     timeIndex.renameTo(new File(Utils.replaceSuffix(timeIndex.file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
-                    txnIndex.renameTo(new File(Utils.replaceSuffix(txnIndex.file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
+                    if (txnIndexOpt.isPresent()) {
+                        txnIndexOpt.get().renameTo(new File(Utils.replaceSuffix(txnIndexOpt.get().file().getPath(), "", LogFileUtils.DELETED_FILE_SUFFIX)));
+                    }

Review Comment:
   You can use txnIndexOpt.ifPresent()



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -545,7 +557,9 @@ public void cleanup() throws IOException {
                         timeIndex.deleteIfExists();
                         return null;
                     }, () -> {
-                        txnIndex.deleteIfExists();
+                        if (txnIndexOpt.isPresent()) {
+                            txnIndexOpt.get().deleteIfExists();
+                        }

Review Comment:
   you can use txnIndexOpt.ifPresent()



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -573,8 +587,7 @@ public String toString() {
             return "Entry{" +
                     "offsetIndex=" + offsetIndex.file().getName() +
                     ", timeIndex=" + timeIndex.file().getName() +
-                    ", txnIndex=" + txnIndex.file().getName() +
-                    '}';
+                    ", txnIndex=" + txnIndexOpt.map(index -> index.file().getName()) + '}';

Review Comment:
   I guess this will print "Optional.empty" here? Do we want to print empty string instead?



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -382,6 +388,9 @@ private RemoteIndexCache.Entry createCacheEntry(RemoteLogSegmentMetadata remoteL
             TransactionIndex txnIndex = loadIndexFile(txnIndexFile, remoteLogSegmentMetadata, rlsMetadata -> {
                 try {
                     return remoteStorageManager.fetchIndex(rlsMetadata, IndexType.TRANSACTION);
+                } catch (RemoteResourceNotFoundException e) {
+                    // Don't throw an exception since the transaction index may not exist because of no transactional records.
+                    return null;

Review Comment:
   please add a javadoc for the usage of this method that null is expected



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] divijvaidya commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1321638678


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -382,6 +388,9 @@ private RemoteIndexCache.Entry createCacheEntry(RemoteLogSegmentMetadata remoteL
             TransactionIndex txnIndex = loadIndexFile(txnIndexFile, remoteLogSegmentMetadata, rlsMetadata -> {
                 try {
                     return remoteStorageManager.fetchIndex(rlsMetadata, IndexType.TRANSACTION);
+                } catch (RemoteResourceNotFoundException e) {
+                    // Don't throw an exception since the transaction index may not exist because of no transactional records.
+                    return null;

Review Comment:
   yes please. I know it is not necessary for private methods but it would be useful for future code implementors to understand that they are expected to handle nulls returned by this method. 



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] kamalcph commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1322597671


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -382,6 +388,9 @@ private RemoteIndexCache.Entry createCacheEntry(RemoteLogSegmentMetadata remoteL
             TransactionIndex txnIndex = loadIndexFile(txnIndexFile, remoteLogSegmentMetadata, rlsMetadata -> {
                 try {
                     return remoteStorageManager.fetchIndex(rlsMetadata, IndexType.TRANSACTION);
+                } catch (RemoteResourceNotFoundException e) {
+                    // Don't throw an exception since the transaction index may not exist because of no transactional records.
+                    return null;

Review Comment:
   I got confused with this statement:
   
   > This one is the caller and the second parameter could receive null input stream.
   
   It's the third parameter. Can you place the one parameter per line for readability?



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] abhijeetk88 commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "abhijeetk88 (via GitHub)" <gi...@apache.org>.
abhijeetk88 commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1321001330


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -382,6 +385,8 @@ private RemoteIndexCache.Entry createCacheEntry(RemoteLogSegmentMetadata remoteL
             TransactionIndex txnIndex = loadIndexFile(txnIndexFile, remoteLogSegmentMetadata, rlsMetadata -> {
                 try {
                     return remoteStorageManager.fetchIndex(rlsMetadata, IndexType.TRANSACTION);
+                } catch (RemoteResourceNotFoundException e) {
+                    return null;

Review Comment:
   Added.



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -451,7 +456,7 @@ public static class Entry implements AutoCloseable {
 
         private final OffsetIndex offsetIndex;
         private final TimeIndex timeIndex;
-        private final TransactionIndex txnIndex;
+        private final Optional<TransactionIndex> txnIndexOpt;

Review Comment:
   Added



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] satishd commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1320672481


##########
core/src/test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala:
##########
@@ -143,6 +143,28 @@ class RemoteIndexCacheTest {
     verifyNoInteractions(rsm)
   }
 
+  @Test
+  def testFetchIndexForMissingTransactionIndex(): Unit = {
+    when(rsm.fetchIndex(any(classOf[RemoteLogSegmentMetadata]), any(classOf[IndexType])))

Review Comment:
   I may be missing something here. How is this test validating the actual implementation?



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] kamalcph commented on a diff in pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14363:
URL: https://github.com/apache/kafka/pull/14363#discussion_r1321200355


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -573,8 +587,7 @@ public String toString() {
             return "Entry{" +
                     "offsetIndex=" + offsetIndex.file().getName() +
                     ", timeIndex=" + timeIndex.file().getName() +
-                    ", txnIndex=" + txnIndex.file().getName() +
-                    '}';
+                    ", txnIndex=" + txnIndexOpt.map(index -> index.file().getName()) + '}';

Review Comment:
   Won't this throw NPE?



-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] abhijeetk88 commented on pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "abhijeetk88 (via GitHub)" <gi...@apache.org>.
abhijeetk88 commented on PR #14363:
URL: https://github.com/apache/kafka/pull/14363#issuecomment-1715075026

   @divijvaidya @showuon I have addressed your comments. Please take a look.


-- 
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-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] satishd commented on pull request #14363: KAFKA-14993: Improve TransactionIndex instance handling while copying to and fetching from RSM

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on PR #14363:
URL: https://github.com/apache/kafka/pull/14363#issuecomment-1712704385

   cc @ivanyu , as he requested it for 3.6.0


-- 
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-unsubscribe@kafka.apache.org

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