Skip to content

Fix Lucene error from ChecksumException to TimeoutException - #4844

Merged
ohadzeliger merged 5 commits into
FoundationDB:mainfrom
ohadzeliger:supressed-exception
Nov 10, 2026
Merged

ohadzeliger merged 5 commits into
FoundationDB:mainfrom
ohadzeliger:supressed-exception

Conversation

@ohadzeliger

@ohadzeliger ohadzeliger commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes an issue with the way Lucene handles a read failure. Before the change, a timeout error when opening an Index Input would fail with a checksum error due to the Input recording the byte as read although it was not. With this fix, a byte will only count as read if the operation succeeded.The issue that actually exposed this bug is that the checksum would be miscalculated as the reader would continue to read bytes trying to get to the footer.

…ut should have the cause be the original exception
@ohadzeliger ohadzeliger self-assigned this Nov 4, 2026
@ohadzeliger ohadzeliger added the bug fix Change that fixes a bug label Nov 4, 2026
@ohadzeliger
ohadzeliger marked this pull request as ready for review November 4, 2026 21:31
Comment on lines 268 to 269
position++;
verify(data != null, "current Data is null: " + fileName + " " + fileReference.getId());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this should be after the verify call. If the verify fails (which it shouldn't), it would mean the position advanced, and you could potentially get the same issue with reading the footer and seeing a different hash (although that would require the second read to not have getCurrentData() return null).

Suggested change
position++;
verify(data != null, "current Data is null: " + fileName + " " + fileReference.getId());
verify(data != null, "current Data is null: " + fileName + " " + fileReference.getId());
position++;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done.

new LuceneConcurrency.AsyncToSyncTimeoutException("Blah", new TimeoutException("Blah")), 0);

try (FDBIndexInput input = new FDBIndexInput("testReadByte", directory)) {
final IOException ex = assertThrows(IOException.class, input::readByte);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjacent to this issue, perhaps it would make sense to add the same test for readBytes. Looking at the code, I don't see a bug, but it's worth having for regression and consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added another case for the unit test. The system-wide test is harder as creating a scenario for readBytes is more involved

@ohadzeliger ohadzeliger changed the title Fix Lucene exception misalignment Fix Lucene error from ChecksumException to TimeoutException Nov 10, 2026
@ohadzeliger
ohadzeliger merged commit 1e6d98a into FoundationDB:main Nov 10, 2026
12 checks passed
@ohadzeliger
ohadzeliger deleted the supressed-exception branch November 10, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Change that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants