Disconnect
Disconnects from a ClickHouse database server and releases the connection.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Connection Id - The connection ID returned from the Connect node.
How It Works
The Disconnect node closes an active ClickHouse database connection and releases its resources. When executed, the node:
- Validates that a connection ID is provided
- Retrieves the connection from the internal connection pool
- Closes the database connection
- Removes the connection from the internal pool
- Releases all associated resources
Requirements
- A valid connection ID from a previous Connect node
- The connection must still be active (not already closed)
Error Handling
The node will return specific errors in the following cases:
- InvalidConnection - Connection not found (connection ID is invalid or connection was already closed)
- Database close errors (network issues, server problems)
Usage Notes
- Always use Disconnect to properly clean up database connections
- Disconnecting a connection that is no longer valid will result in an error
- After disconnecting, the connection ID becomes invalid and cannot be reused
- Any ongoing transactions on the connection will be rolled back automatically
- Ensure all queries and batches are completed before disconnecting
Example
Scenario: Close the connection after completing all database operations
Inputs:
- Connection Id: "550e8400-e29b-41d4-a716-446655440000" (from Connect node)
Output: No output - the connection is simply closed and removed from the pool.
Best Practices
- Always pair Connect nodes with Disconnect nodes
- Place Disconnect at the end of your database workflow
- Use error handling to ensure Disconnect runs even if earlier operations fail
- Consider using a Try-Catch-Finally pattern with Disconnect in the Finally block
- Don't attempt to use the connection ID after disconnecting
Common Flow Pattern
A typical ClickHouse automation flow follows this pattern:
1. Connect → Get connection ID
2. Execute Query/Non Query operations → Use connection ID
3. Disconnect → Clean up connection
For error-safe patterns:
Try:
1. Connect
2. Execute operations
Catch:
- Handle errors
Finally:
- Disconnect (always runs)
Resource Management
- Disconnecting releases memory and network resources
- Failing to disconnect can lead to connection pool exhaustion
- ClickHouse servers have connection limits - always clean up connections
- Idle connections may be automatically closed by the server after a timeout
- Proper disconnection helps maintain optimal server performance