Core: Restore the interrupt status in JdbcCatalog.execute - #17492
Open
PDGGK wants to merge 1 commit into
Open
Conversation
uros-b
reviewed
Aug 3, 2026
| Thread.currentThread().interrupt(); | ||
| // purge = false keeps this on the execute() path. The default purge = true would first | ||
| // read table metadata through fetch(), which already restores the interrupt status. | ||
| assertThatThrownBy( |
Member
There was a problem hiding this comment.
This assert has no .hasMessage(...) / .hasMessageContaining(...) assertion. Iceberg's checkstyle rule AssertThatThrownByWithMessageCheck requires a message check on every assertThatThrownBy chain.
execute() is the only one of the four InterruptedException handlers in JdbcCatalog that rethrows without calling Thread.currentThread().interrupt(); initializeCatalogTables, updateSchemaIfRequired and fetch all restore it. execute() backs every write path - dropTable, renameTable, renameView, dropNamespace and the namespace property insert/update/delete - so a task cancelled while waiting for a pooled connection loses the interrupt status and any caller that checks it afterwards sees a thread that was never interrupted.
PDGGK
force-pushed
the
fix-jdbc-catalog-interrupt-status
branch
from
August 3, 2026 12:11
8aacaaf to
85c9952
Compare
Contributor
Author
|
Good catch, thanks — fixed in That was my miss: I ran
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JdbcCataloghas fourInterruptedExceptionhandlers. Three of them restore the interrupt status before rethrowing;executedoes not.initializeCatalogTables(:227)updateSchemaIfRequired(:268)execute(:781)fetch(:814)executebacks every write path —dropTable,renameTable,renameView,dropNamespaceand the namespace property insert/update/delete — so a task cancelled while waiting for a pooled connection ends up with a thread whose interrupt status has been cleared byObject.wait. Anything downstream that pollsThread.interrupted()to decide whether to stop, including the executors Spark and Flink use to cancel work, sees a thread that was never interrupted.The fix is the same one line the other three handlers already have.
Testing
TestJdbcCatalog.testExecuteRestoresInterruptStatusbuilds a catalog withclients=1, holds the single pooled connection from another thread through the existing@VisibleForTesting connectionPool()accessor, interrupts the test thread, and asserts thatdropTableboth throwsUncheckedInterruptedExceptionand leaves the interrupt status set. It fails onmainwithExpecting value to be true but was falseand passes with this change. Two latches rather than sleeps, so there is no timing window.One thing worth flagging for whoever reviews the test: it has to call
dropTable(ident, false). The single-argumentdropTabledefaults topurge = true, which reads table metadata throughfetchfirst — andfetchalready restores the status, so the assertion would pass even without the fix. The same trap applies todropNamespaceand the property setters.:iceberg-core:test --tests "org.apache.iceberg.jdbc.*"— passes:iceberg-core:spotlessCheck— passes