New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-15511: Catch CorruptIndexException instead of CorruptRecordException #14459
Conversation
…alling index SanityCheck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Left some minor comments.
core/src/test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala
Outdated
Show resolved
Hide resolved
@@ -310,7 +310,7 @@ private <T> T loadIndexFile(File file, RemoteLogSegmentMetadata remoteLogSegment | |||
if (Files.exists(indexFile.toPath())) { | |||
try { | |||
index = readIndex.apply(indexFile); | |||
} catch (CorruptRecordException ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can CorruptRecordException
be thrown in some scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Hangleton The RemoteIndexCache caches only index files which needs to be checked for corruption. There is no such record concept in RemoteIndexCache.
@divijvaidya @satishd can add more details here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I wanted to confirm that it is indeed the case although we are dealing with indexes here. The rationale being that CorruptRecordException
may have been introduced purposefully to cover a use case. Was this not covered by a test in the initial PR, and if it was, did the test make an incorrect assumption, or exercised an invalid (that is, impossible) scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this not covered by a test in the initial PR
@Hangleton no we don't have a test case to execute this code. In fact, the bug fixed this PR was discovered while working on the task [1] to add more unit test for remote index cache.
e81ca46
to
5bc38e4
Compare
5bc38e4
to
e18d6fd
Compare
Test failures are unrelated to Tiered Storage code.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good to me.
@Hangleton @satishd since you folks participated in the review for this PR, do you have any additional comments? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for fixing this issue!
Do you know the reason behind CorruptIndexException
directly extends the RuntimeException
instead of KafkaException
?
@@ -598,4 +615,13 @@ class RemoteIndexCacheTest { | |||
timeIndex.flush() | |||
} | |||
} | |||
|
|||
private def createCorruptRemoteIndexCacheOffsetFile(): Unit = { | |||
val pw = new PrintWriter((remoteOffsetIndexFile(new File(tpDir, RemoteIndexCache.DIR_NAME),rlsMetadata))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space after comma and remove extra brackets
Unrelated test failures
|
@divijvaidya It seems i don't have permission to merge it even after the approval. |
A bug in the RemoteIndexCache leads to a situation where the cache does not replace the corrupted index with a new index instance fetched from remote storage. This commit fixes the bug by adding correct handling for `CorruptIndexException`. Reviewers: Divij Vaidya <diviv@amazon.com>, Satish Duggana <satishd@apache.org>, Kamal Chandraprakash <kamal.chandraprakash@gmail.com>, Alexandre Dupriez <duprie@amazon.com>
Merged to trunk and 3.6. Thank you for the contribution @iit2009060. For Apache projects, only the committers can merge code into the repository. |
Thanks for the fix @iit2009060 ! Nice find! |
…#14459) A bug in the RemoteIndexCache leads to a situation where the cache does not replace the corrupted index with a new index instance fetched from remote storage. This commit fixes the bug by adding correct handling for `CorruptIndexException`. Reviewers: Divij Vaidya <diviv@amazon.com>, Satish Duggana <satishd@apache.org>, Kamal Chandraprakash <kamal.chandraprakash@gmail.com>, Alexandre Dupriez <duprie@amazon.com>
…#14459) A bug in the RemoteIndexCache leads to a situation where the cache does not replace the corrupted index with a new index instance fetched from remote storage. This commit fixes the bug by adding correct handling for `CorruptIndexException`. Reviewers: Divij Vaidya <diviv@amazon.com>, Satish Duggana <satishd@apache.org>, Kamal Chandraprakash <kamal.chandraprakash@gmail.com>, Alexandre Dupriez <duprie@amazon.com>
…#14459) A bug in the RemoteIndexCache leads to a situation where the cache does not replace the corrupted index with a new index instance fetched from remote storage. This commit fixes the bug by adding correct handling for `CorruptIndexException`. Reviewers: Divij Vaidya <diviv@amazon.com>, Satish Duggana <satishd@apache.org>, Kamal Chandraprakash <kamal.chandraprakash@gmail.com>, Alexandre Dupriez <duprie@amazon.com>
Scenario
The bug occurs when RemoteIndexCache does not have an entry but CorruptedIndex File exists in the desired path.
Current behaviour
It will throw the CorruptIndex Exception and does not recover or replace the CorruptedIndexFile with new File fetch from remote storage.
Desired Behaviour
It should catch the CorruptIndex Exception and should refetch it from remote storage and overwrite the corrupted file.
Testing
Written Unit Test to test the above scenario
Committer Checklist (excluded from commit message)