Repository navigation
feat(duckdb): add query timeout - #314
Open
vincentsarago wants to merge 1 commit into
Open
vincentsarago wants to merge 1 commit into
vincentsarago wants to merge 1 commit into
Conversation
Add `TIPG_DUCKDB_QUERY_TIMEOUT` (seconds, disabled by default). Items (including the `numberMatched` count) and tiles queries still running after the timeout are interrupted (`cursor.interrupt()`) and return a `504 Gateway Timeout` (new `QueryTimeout` error). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Stacked on #307.
Why
A single expensive DuckDB query (e.g. a low zoom tile over a large, unsorted remote GeoParquet file) can keep a worker busy for minutes: a z5 tile over a 2.3M-polygon remote file read the whole ~870 MB file and took ~55s.
What
query_timeoutsetting (TIPG_DUCKDB_QUERY_TIMEOUT, seconds) inDuckDBCatalogSettings. Disabled by default.numberMatchedCOUNT(*)) and tiles queries still running after the timeout are interrupted withcursor.interrupt().QueryTimeouterror, mapped to504 Gateway TimeoutinDEFAULT_STATUS_CODES.docs/src/advanced/duckdb.md(settings table and the low zoom levels section).On DuckDB 2.0, an interrupt stops the query within ~0.3s. The cursor and the connection are still usable after it, and interrupting a cursor whose query already finished doesn't affect its next queries.
Not covered
Tests
tests/duck/test_timeout.pyuses a view over 10¹¹ rows with a 0.5s timeout:Full test suite passes locally (145 tests).
🤖 Generated with Claude Code