Quick onboard
Deployment
Data Modeling
Connecting
Migration
Query
Operations and Maintenance
Common Maintenance
Partition
Backup and Restore
Expansion
Mirroring
Resource Groups
Security
Monitoring
Performance Tuning
Troubleshooting
Reference Guide
Tool guide
Data type
Storage Engine
Executor
Stream
DR (Disaster Recovery)
Configuration
Index
Extension
SQL Reference
YMatrix supports Runaway detection. For queries managed by resource groups, YMatrix can automatically terminate queries based on their memory consumption.
Relevant configuration parameters include:
gp_vmem_protect_limit: Sets the total amount of memory that all postgres processes in an active segment instance can consume. If a query causes this limit to be exceeded, no additional memory is allocated, and the query fails.runaway_detector_activation_percent: When resource groups are enabled, if memory usage exceeds gp_vmem_protect_limit * runaway_detector_activation_percent, YMatrix begins terminating queries managed by resource groups (excluding those in system_group), starting with the query consuming the most memory. Termination continues until memory usage drops below the specified threshold.RESOURCE GROUP clause in CREATE ROLE or ALTER ROLE to assign a resource group to a database role:ALTER ROLE bill RESOURCE GROUP rg_light;
CREATE ROLE mary RESOURCE GROUP exec;
A resource group can be assigned to one or more roles. If a role hierarchy exists, the resource group assigned to a parent role does not propagate to its member roles.
NONE:ALTER ROLE mary RESOURCE GROUP NONE;
View resource group limits:
SELECT * FROM gp_toolkit.gp_resgroup_config;
View current resource group query status:
SELECT * FROM gp_toolkit.gp_resgroup_status;
View memory usage per host for each resource group:
SELECT * FROM gp_toolkit.gp_resgroup_status_per_host;
View which resource groups are assigned to roles:
SELECT rolname, rsgname
FROM pg_roles, pg_resgroup
WHERE pg_roles.rolresgroup = pg_resgroup.oid;
View running and pending queries in resource groups:
SELECT query, rsgname, wait_event_type, wait_event
FROM pg_stat_activity;
Cancel running or queued transactions in a resource group:
To manually cancel a transaction, first identify its process ID (pid). Then call pg_cancel_backend() to terminate it.
Steps:
SELECT rolname, g.rsgname, pid, waiting, state, query, datname
FROM pg_roles, gp_toolkit.gp_resgroup_status g, pg_stat_activity
WHERE pg_roles.rolresgroup = g.groupid
AND pg_stat_activity.usename = pg_roles.rolname;
rolname | rsgname | pid | waiting | state | query | datname
---------+----------+-------+---------+--------+--------------------------+---------
sammy | rg_light | 31861 | f | idle | SELECT * FROM mytesttbl; | testdb
billy | rg_light | 31905 | t | active | SELECT * FROM topten; | testdb
SELECT pg_cancel_backend(31905);
Note!
Do not use the operating systemKILLcommand to terminate any YMatrix database process.
Superusers can use the gp_toolkit.pg_resgroup_move_query() function to move a running query from one resource group to another without stopping it. This is useful for accelerating long-running queries by moving them to a resource group with higher allocation or availability.
pg_resgroup_move_query() affects only the specified query; subsequent queries from the same session remain assigned to the original resource group.
Note!
Only active (running) queries can be moved. Idle, queued, or pending queries—those blocked due to concurrency or memory limits—cannot be moved.
The function requires the query’s process ID (pid) and the target resource group name:
pg_resgroup_move_query(pid int4, group_name text);
As described in the section on canceling transactions, you can use the gp_toolkit.gp_resgroup_status view to list resource group names, IDs, and statuses.
When pg_resgroup_move_query() is called, the running query becomes subject to the target resource group’s configuration, including concurrency and memory limits:
gp_resource_group_queuing_timeout (if set) expires.pg_resgroup_move_query() attempts to transfer slot ownership to the target process for up to gp_resource_group_move_timeout milliseconds. If the transfer isn’t completed within this time, an error is returned.After a query is moved, there is no guarantee that the total memory usage of running queries in the target group will stay within its MEMORY_QUOTA. In such cases, one or more queries—including the moved one—may fail. To minimize this risk, ensure adequate global shared memory is reserved for the resource group.