Skip to content

Conversation

@staticlibs
Copy link
Collaborator

The implementation of Statement#setQueryTimeout() added in #247 uses a background thread to perform the query cancellation on timeout. Because that thread is not marked as "daemon" one, it can prevent JVM shutdown.

This change makes the scheduler thread "daemon" and additionally exposes DuckDBDriver#shutdownQueryCancelScheduler() method that allows to shut down the scheduler manually.

Testing: manual test added that checks that queries with timeout set can be executed (with timeout ineffective) after the scheduler is shut down.

Fixes: #504

The implementation of `Statement#setQueryTimeout()` added in duckdb#247 uses a
background thread to perform the query cancellation on timeout. Because
that thread is not marked as "daemon" one, it can prevent JVM shutdown.

This change makes the scheduler thread "daemon" and additionally exposes
`DuckDBDriver#shutdownQueryCancelScheduler()` method that allows to shut
down the scheduler manually.

Testing: manual test added that checks that queries with timeout set
can be executed (with timeout ineffective) after the scheduler is shut down.

Fixes: duckdb#504
@staticlibs staticlibs merged commit 3b3afd4 into duckdb:main Jan 8, 2026
12 checks passed
@staticlibs staticlibs deleted the scheduler_daemon branch January 8, 2026 23:20
staticlibs added a commit to staticlibs/duckdb-java that referenced this pull request Jan 8, 2026
This is a backport of the PR duckdb#505 to `v1.4-andium` stable branch.

The implementation of `Statement#setQueryTimeout()` added in duckdb#247 uses a
background thread to perform the query cancellation on timeout. Because
that thread is not marked as "daemon" one, it can prevent JVM shutdown.

This change makes the scheduler thread "daemon" and additionally exposes
`DuckDBDriver#shutdownQueryCancelScheduler()` method that allows to shut
down the scheduler manually.

Testing: manual test added that checks that queries with timeout set
can be executed (with timeout ineffective) after the scheduler is shut down.

Fixes: duckdb#504
staticlibs added a commit that referenced this pull request Jan 9, 2026
This is a backport of the PR #505 to `v1.4-andium` stable branch.

The implementation of `Statement#setQueryTimeout()` added in #247 uses a
background thread to perform the query cancellation on timeout. Because
that thread is not marked as "daemon" one, it can prevent JVM shutdown.

This change makes the scheduler thread "daemon" and additionally exposes
`DuckDBDriver#shutdownQueryCancelScheduler()` method that allows to shut
down the scheduler manually.

Testing: manual test added that checks that queries with timeout set
can be executed (with timeout ineffective) after the scheduler is shut down.

Fixes: #504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JVM does not exit after closing connections when queryTimeout is used

1 participant