Skip to content

ADBC: statement interrupt/cancel is surfaced as QueryTimeoutError #687

Description

@cofin

create_mapped_exception in sqlspec/adapters/adbc/core.py (0.58.2) maps both SQLSTATE 57014 and the message patterns cancel/interrupt to QueryTimeoutError.

Calling connection.adbc_cancel() from another thread to cancel an in-flight DuckDB statement makes execute_script fail with INVALID_ARGUMENT: INTERRUPT Error, which then surfaces as:

sqlspec.exceptions.QueryTimeoutError: ADBC query timeout: INVALID_ARGUMENT: INTERRUPT Error

That's misleading for anyone reading logs or writing handlers—the statement was deliberately cancelled, not timed out—and callers implementing cooperative cancellation can only tell the two apart by string-matching the message.

Proposal: map interrupt/cancel (SQLSTATE 57014, message patterns cancel/interrupt) to a distinct exception, such as OperationCancelledError—ideally a QueryTimeoutError sibling rather than subclass, since retry policies for timeouts and user cancellations usually differ. Happy to PR if the direction sounds right.

Repro sketch: DuckDB AdbcConfig session running a long execute_script; a second thread calls driver.connection.adbc_cancel(); observe QueryTimeoutError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions