This is a preview feature. Preview features may be operationally incomplete and may offer limited backward compatibility.
Interrupting active server connections
The md_interrupt_server_connection
scalar function can be used to interrupt an active transaction on a server-side connection.
This will interrupt and fail / rollback the active transaction (when executing for example a long-running query), but will allow the connection to be used for future transactions and queries.
The function takes as input the client_connection_id
, i.e. the unique identifier for the client DuckDB connection that initiated the server connection.
Syntax
SELECT md_interrupt_server_connection(<client_connection_id>);
Example usage
Interrupting a specific connection:
SELECT md_interrupt_server_connection('2601e799-51b3-47a7-a64f-18688d148887');
Using md_interrupt_server_connection
in conjunction with md_active_server_connections
to interrupt a subset or all of the currently active connections:
-- Interrupt all connections where a `CREATE TABLE` query is running
SELECT md_interrupt_server_connection(client_connection_id)
FROM md_active_server_connections()
WHERE starts_with(client_query, 'CREATE TABLE');