I want to know why Amazon Redshift Serverless canceled or stopped my query, and I receive an error message.
Short description
The following are reasons why a query is canceled or stopped in Amazon Redshift:
- You reached the query quota.
- You reached the workgroup usage quota for Redshift processing units (RPUs).
- Your query exceeded the statement_timeout value.
- Another user stopped or canceled the query.
- There are issues with the network connection.
Resolution
Check the Amazon Redshift Serverless workgroup query quota
When you reach the workgroup query quota, the query returns the following error message:
"ERROR: Query (6800381) cancelled on user's request."
To confirm that Amazon Redshift canceled the query because you reached the quota, run the following SQL statement from the Amazon Redshift query editor:
SELECT query_id, query_text, error_message from SYS_QUERY_HISTORY WHERE error_message ILIKE '%cancelled on user%';
To resolve this issue, increase your workgroup query quota.
Check the Amazon Redshift Serverless workgroup usage quota for RPUs
When you reach the workgroup usage quota for RPUs, the query returns the following error message:
"Error: Query reached usage limit."
To confirm that Amazon Redshift canceled the query because you reached the usage quota, run the following SQL statement from the Amazon Redshift query editor:
SELECT query_id, query_text, usage_limit, error_message FROM SYS_QUERY_HISTORY WHERE error_message ILIKE '%reached usage limit%';
To resolve this issue, increase your workgroup usage quota.
Check whether your query exceeded the statement_timeout value
When a query exceeds the statement_timeout value, Amazon Redshift cancels the queries that you submit during the session. The query returns the following error message:
"ERROR: Query (150) cancelled on user's request."
To check the statement timeout for your cluster, run the following SQL statement from the Amazon Redshift query editor:
SHOW statement_timeout;
The statement shows the cluster-level statement timeout in milliseconds. To change the output, modify parameters in the workload management configuration.
To confirm that Amazon Redshift canceled the query 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 Amazon Redshift canceled your query, then run the following command to increase your statement_timeout value:
SET statement_timeout = (value)
Note: Replace (value) with a higher value than the previous statement_timeout value.
Check whether another user stopped or canceled the query
To check whether 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 stopped 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 stopped or canceled the query.
Note: Users can stop only their own session. A superuser can stop all sessions.
Network issues
Network issues can also cancel queries.
To check whether there's an issue with the network connection, run the following command to check the SYS_CONNECTION_LOG monitoring view:
SELECT * FROM SYS_CONNECTION_LOG WHERE session_id = process_id;
Note: Replace process_id with your process ID.
Related information
Why was my query canceled in Amazon Redshift?