Help Center/ GaussDB(DWS)/ Troubleshooting/ Database Parameter Modification/ SQL Execution Fails With the Error Message "canceling statement due to statement timeout" Reported
Updated on 2025-04-10 GMT+08:00

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.

  1. Log in to the GaussDB(DWS) console.
  2. Choose Dedicated Clusters > Clusters in the navigation pane.
  3. In the cluster list, find the target cluster and click the cluster name. The Cluster Information page is displayed.
  4. Click Parameter Modifications, find statement_timeout in the parameter list, change its value, and click Save.

    By default, GaussDB(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.

  5. In the Modification Preview dialog box, confirm the modification and click Save.

Method 2: Connect to the cluster and run an SQL command to change the value of statement_timeout.
  • Use the SET statement to change the value (session level):
    1
    SET statement_timeout TO 0;
    
  • Run the ALTER ROLE statement to change the value (user level):
    1
    ALTER 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.