Help Center/ GaussDB(DWS)/ Troubleshooting/ Database Parameter Modification/ SQL Execution Fails With the Error Message "canceling statement due to statement timeout" Reported
Updated on 2024-01-25 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) management console.
  2. In the navigation pane on the left, choose Clusters.
  3. In the cluster list, find the target cluster and click its name. The cluster information page is displayed.
  4. Click the Parameter Modifications tab and modify the value of parameter session_timeout. 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.
  6. If No is displayed in the Restart Cluster column of the statement_timeout parameter, the parameter modification takes effect immediately without restart.

    Figure 1 Modifying the statement_timeout parameter

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.