The statement_timeout value is the maximum amount of time that a query runs before Amazon Redshift terminates it. When a statement_timeout value is exceeded, queries that you submit during the session are canceled. The query returns an error message similar to the following one:
"ERROR: Query (150) cancelled on user's request."
To confirm that the query is canceled because of a statement timeout, run the following SQL statement from the Amazon Redshift Query Editor:
select * from SYS_QUERY_HISTORY where query_text ilike '%set%statement_timeout%to%';
If your query is canceled because of a statement timeout, then increase your statement_timeout value:
set statement_timeout = (value)
Note: Replace (value) with a higher value than the previous statement_timeout value.
Check if another user stopped or canceled the query
To check if another user stopped or canceled a query, run the following command and review the error_message column:
select * from sys_query_history where session_id = process_id;
Note: Replace process_id with your process ID.
To view terminated queries, run the following SQL statement from Amazon Redshift Query Editor:
select * from sys_query_history where error_message ilike '%terminate%';
To view canceled queries, run the following SQL statement from Amazon Redshift Query Editor:
select * from sys_query_history where error_message ilike '%canceled by user%';
If the query appears in the output, then a user request stopped or canceled the query.
Note: Users can terminate only their own session. A superuser can terminate all sessions.
Queries might be canceled because of underlying network issues. To check if there's an issue with the network connection, review the SYS_CONNECTION_LOG monitoring view.
Run the following command to check the SYS_CONNECTION_LOG monitoring view:
select * from SYS_CONNECTION_LOG where session_id = process_id;