SQL Execution Fails With the Error Message "canceling statement due to statement timeout" Reported
Symptom
When an SQL statement is executed for more than 2 hours, the following error information is displayed:
1 | ERROR: canceling statement due to statement timeoutTime. |
Possible Causes
If the execution time of a statement exceeds the time specified by statement_timeout, an error is reported and the statement execution exits.
Handling Procedure
Method 1: Modify the statement_timeout parameter on the console.
- Log in to the DWS console.
- Choose Cluster > Cluster List in the navigation pane.
- In the cluster list, find the target cluster and click the cluster name. The Cluster Information page is displayed.
- Click Parameter Modifications, find statement_timeout in the parameter list, change its value, and click Save.
By default, DWS does not trigger SQL timeout. The default value of statement_timeout is 0. If you have manually modified this parameter, you are advised to change it back to the default value 0 or set it to a proper value to prevent SQL timeout affecting other tasks.
- In the Modification Preview dialog box, confirm the modification and click Save.
- Use the SET statement to change the value (session level):
1SET statement_timeout TO 0;
- Run the ALTER ROLE statement to change the value (user level):
1ALTER USER username SET statement_timeout TO 600000;
In the preceding command, username indicates the user name of the database for which the SQL statement timeout interval is to be set.