Why is my Amazon Redshift Serverless query canceled or stopped?

3 minute read
0

I want to know why my Amazon Redshift Serverless query is canceled or stopped, and I receive an error message.

Short description

The following are common reasons why a query is canceled or stopped in Amazon Redshift:

  • The workgroup query limit is reached.
  • The workgroup usage limit is reached.
  • The statement_timeout value is exceeded.
  • Another user stopped or canceled the query.
  • There are issues with the network connection.

Resolution

Check the Amazon Redshift Serverless workgroup query limit

Open the Amazon Redshift console, and review the query limit for a workgroup. If a query is canceled because of a workgroup query limit, then the query returns the following error message:

"ERROR: Query (6800381) cancelled on user's request."

To confirm that the query is canceled because of a query limit, run the following SQL statement from 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 limit.

Check the Amazon Redshift Serverless workgroup usage limit

Open the Amazon Redshift console, and review the usage limit in Redshift processing units (RPUs). If a query is canceled because of a usage limit, then the query returns the following error message:

"Error: Query reached usage limit."

To confirm that the query is canceled because of a usage limit, 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 limit.

Check if the statement_timeout value is exceeded

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.

Network issues

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;

Note: Replace process_id with your process ID.

Related information

Why was my query canceled in Amazon Redshift?

AWS OFFICIAL
AWS OFFICIALUpdated 9 months ago