Number of Queuing Query Statements Exceeds the Threshold
Description
During the execution of service queries, the database may choose to store the temporary result to the disk, which is called Operator Spilling.
GaussDB(DWS) checks the load management records of jobs being executed on CNs through the GS_WLM_SESSION_STATISTICS view every 60 seconds and calculates the maximum amount of data spilled to DNs.
If the number of SQL statements spilled to disks exceeds 5 GB (configurable) within 10 minutes (configurable), an alarm is reported indicating that a query statement triggers the data spill threshold. This alarm is automatically cleared when the data spill drop below the alarm conditions.
If blocked SQL statements that can trigger the alarm persists, the alarm is generated again after 24 hours (configurable).
Attributes
| Alarm Granularity | Alarm Severity | Auto Clear |
|---|---|---|
| Cluster | Critical | Yes |
Parameters
| Parameter | Description |
|---|---|
| Source | Indicates the name of the system for which the alarm is generated and the detailed alarm type. |
| Cluster Name | ID of the cluster for which the alarm is generated |
| Location Information | ID and name of the cluster for which the alarm is generated |
| Other Information | CloudService indicates the cloud service for which the alarm is generated, including the service name, resource ID, resource name, database name, username connecting to the backend, and query ID. first_alarm_time indicates the time when the alarm is generated for the first time. query statement indicates the query statement that triggers the alarm, along with the amount of data spilled to disks caused by the query statement. Example: CloudService=DWS,resourceId: xxxx-xxxx-xxxx-xxxx, resourceIdName: test_dws, db_name: test_db, user_name: test_user, query_id: 756942385413326696, first_alarm_time: 2022-12-30:12:42:77: query statement (ID= 756942385413326696) select num,value,cnt,rk,cnt/sumcnt as ratio,sum(ratio) over (over by rk) as cumuratio from...; The result set is spilled to disks, and the spill size is 15 GB. |
| Time | Indicates the time when the alarm was generated. |
| Status | Indicates the current status of an alarm. |
You can connect to the database and run the SELECT * FROM GS_WLM_SESSION_STATISTICS command to view the max_spill_size column in the view.
Impact on the System
If a large amount of data spills to disks, a large number of system I/O resources are occupied. As a result, the data disk space may be insufficient or exhausted, triggering the database to become read-only and interrupting services.
Possible Causes
- The amount of service data spilled to disks exceeds the alarm threshold.
- The performance of the SQL query plan is poor, causing a large amount of data to be imported to the memory and spilled to disks.
- Expired data is not cleared in a timely manner. As a result, too much invalid data is scanned and spilled to disks.
Handling Procedure
- Check whether the execution plan is poor in performance.
- Obtain the SQL statement from the additional information of the alarm, run the ANALYZE statement on the involved tables. Run the SQL statement again, and check whether the amount of data spilled to disks decreases.
- If there is no obvious effect, run the EXPLAIN PERFORMANCE command to view the actual execution information of the alarm SQL statement. For details, see SQL Execution Plan. If both the estimated memory usage and the actual memory usage have high peaks, optimize the query. For details, see Optimization Process.
- Check whether the alarm configuration is proper.
- Return to the GaussDB(DWS) management console and choose Alarms > Alarm Rule.

- Click Modify in the Operation column of the row that contains Data Flushed to Disks of the Query Statement Exceeds the Threshold. The Modifying an Alarm Rule page is displayed.

- If the cluster disk capacity is high, you can increase the alarm reporting threshold. It is recommended that the alarm reporting threshold be less than or equal to 5% of the capacity of a single data disk.
If the threshold is too large, data spilled to a disk may cause disk usage alarms or even the cluster to be read-only. If the data disk usage is close to or exceeds 80%, you are advised to clear unnecessary data when adjusting the threshold. For details about the GUI configuration, see Alarm Rules.
- Return to the GaussDB(DWS) management console and choose Alarms > Alarm Rule.
- Kill the SQL statements that cause large data spills.
- Return to the GaussDB(DWS) management console.
- On the Clusters page, locate the row that contains the cluster for which the alarm is generated and click Monitoring Panel in the Operation column.

- Choose Monitoring > Queries, click
to see the data spill in the Max. DN Data Spill (MB) column. 
- After confirming with the service side, select the query ID of the query to be stopped and click Stop Query.
- Adjust database parameters. For details, see Modifying Database Parameters. Control the disk space for service statements. For details, see Statement Disk Space Control.
Alarm Clearance
This alarm is automatically cleared when data spill drops down to a low level.
Last Article: Node Data Disk Usage Exceeds the Threshold
Next Article: Queue Congestion in the Cluster Default Resource Pool
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.