Skip to content

Why can’t I terminate my query in Amazon Redshift?

2 minute read
0

I tried to terminate a long-running query in Amazon Redshift, but the query continues to run.

Short description

Amazon Redshift can't terminate a query in the following scenarios:

  • The query is in the process of returning results to the client.
  • The query process encounters a critical internal error.

Even after you successfully terminate the query, the query might appear as Running. You must wait for the query rollback process to complete.

Resolution

To check whether the query is in the process of returning results to the client, run the following query:

SELECT state FROM stv_wlm_query_state WHERE query = queryid

Note: Replace queryid with your query ID.

In the output, check whether the state column in STV_WLM_QUERY_STATE is Returning.

To terminate the query, run the following PG_TERMINATE_BACKEND command:

SELECT PG_TERMINATE_BACKEND(PID);

Note: Replace PID with the process ID or session ID.

If the PG_TERMINATE_BACKEND command can't terminate the query, then perform a hard reboot in the Amazon Redshift console.

Note: A hard reboot closes all current connections. You can't reboot a serverless cluster.

If you use Amazon Redshift Serverless, then you must create a support case. In the support case, provide the following information:

  • The ID of the query that you want to terminate
  • Your cluster or workgroup name
  • The time when the issue occurred
  • Actions that you took to resolve the issue
AWS OFFICIALUpdated a year ago
1 Comment

Regarding "If the PG_TERMINATE_BACKEND command can't terminate the query, then perform a hard reboot in the Amazon Redshift console.", when are you going to fix this bug?

replied 4 months ago