Skip to content

Fix ANALYZE being skipped when a query timeout is set - #4389

Open
lakxtxue wants to merge 1 commit into
h2database:masterfrom
lakxtxue:codex/fix-analyze-timeout
Open

lakxtxue wants to merge 1 commit into
h2database:masterfrom
lakxtxue:codex/fix-analyze-timeout

Conversation

@lakxtxue

@lakxtxue lakxtxue commented Sep 9, 2026

Copy link
Copy Markdown

Setting a query timeout causes H2 to skip both explicit and automatic ANALYZE, even when the timeout hasn't expired. The check treats a nonzero session.getCancel() as a cancellation, but that value can also be a future deadline.

This change checks whether the deadline has actually passed. It also makes explicit ANALYZE honor Statement.cancel() while scanning. Automatic analysis stops quietly when canceled, so it doesn't report an already committed write as failed.

The regression tests reproduce the timeout and cancellation issues and check that statistics update normally with a timeout set, while canceled analysis leaves existing statistics unchanged.

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.

1 participant