Skip to content

fix: Improved error handling in SeekableStreamIndexTaskRunner.#19218

Merged
gianm merged 2 commits into
apache:masterfrom
gianm:ssitr-exceptions
Mar 27, 2026
Merged

fix: Improved error handling in SeekableStreamIndexTaskRunner.#19218
gianm merged 2 commits into
apache:masterfrom
gianm:ssitr-exceptions

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Mar 27, 2026

The main improvement is that persist is moved out of a finally block, and now only happens on the normal path. This has two benefits. First, there is no point in persisting on the error path, and the in-memory index might be in a bad state anyway at that point. Second, moving the persist call out of finally fixes an issue where an exception thrown from persist would cause an exception thrown from add to be lost.

This can come up in production when the in-memory index grows too large, causing the main code to throw an OutOfMemoryError, and then something goes wrong with the persist too. In this situation the original OutOfMemoryError would not have been logged.

A secondary improvement is that we catch Throwable rather than Exception to trigger cleanup and when handling errors that occur during cleanup. This ensures we don't miss cleanup tasks when an Error is thrown by the main code, and that we don't lose the original exception if an Error is thrown by the cleanup code.

The main improvement is that "persist" is moved out of a finally block,
and now only happens on the normal path. This has two benefits. First,
there is no point in persisting on the error path, and the in-memory
index might be in a bad state anyway at that point. Second, moving the
persist call out of "finally" fixes an issue where an exception thrown
from "persist" would cause an exception thrown from "add" to be lost.

This can come up in production when the in-memory index grows too large,
causing the main code to throw an OutOfMemoryError, and then something
goes wrong with the persist too. In this situation the original
OutOfMemoryError would not have been logged.

A secondary improvement is that we catch Throwable rather than Exception
to trigger cleanup and when handling errors that occur during cleanup.
This ensures we don't miss cleanup tasks when an Error is thrown by
the main code, and that we don't lose the original exception if an Error
is thrown by the cleanup code.
@gianm gianm closed this Mar 27, 2026
@gianm gianm reopened this Mar 27, 2026
@gianm gianm merged commit be58522 into apache:master Mar 27, 2026
100 of 102 checks passed
@gianm gianm deleted the ssitr-exceptions branch March 27, 2026 20:22
@github-actions github-actions Bot added this to the 37.0.0 milestone Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants