Skip to main content

Concurrency Control and Queuing

Use workload group queues to limit admitted queries and absorb short bursts of traffic in a VeloDB Cloud cluster. When admission slots or required resources are unavailable, queries wait if the group has queue capacity. A full queue rejects new queries.

Queue limits can reduce overload, but they do not guarantee that queries avoid memory errors or meet a latency target. Queries that do not need data scans, including system-table-only queries, can bypass the queue.

Configure a queue​

Use a warehouse SQL user with ADMIN_PRIV to create or alter a workload group. Replace analytics with the cluster name. Workload group creation in VeloDB Cloud requires the FOR clause.

CREATE WORKLOAD GROUP IF NOT EXISTS queue_group FOR analytics
PROPERTIES (
"max_concurrency" = "10",
"max_queue_size" = "20",
"queue_timeout" = "3000"
);

Grant the workload group's USAGE privilege to the users or SQL roles that need it. Connect to the intended cluster and select the group for the session:

SET workload_group = 'queue_group';

See Workload Groups for privileges, user defaults, and other resource properties.

Queue properties​

The following defaults describe the Core 26.1.3 implementation. An existing group can have different values. Check it with SHOW WORKLOAD GROUPS.

PropertyTypeDefaultRangeMeaning
max_concurrencyInteger21474836470-2147483647Maximum admitted queries and total admission slots. With the default one slot per query, this is the concurrent-query limit. 0 admits no queries.
max_queue_sizeInteger00-2147483647Maximum waiting queries. 0 rejects a query when it cannot be admitted immediately.
queue_timeoutInteger00-2147483647Queue wait limit in milliseconds when positive, bounded by the query's execution timeout. 0 uses the query timeout rather than failing immediately.

The example admits up to 10 queries per frontend when each query uses one slot. It allows up to 20 queries to wait, and a waiting query times out after at most 3 seconds, or earlier if its query timeout is shorter. Admission can also be delayed by resource availability.

The query_slot_count session variable changes how many slots one query requests. A query requesting more than one slot can reach the group's slot limit before the number of admitted queries reaches max_concurrency.

Note:

Queues are maintained separately by each frontend (FE), not by a single counter across the warehouse. With max_concurrency = 1, two frontends can each admit one query for the same workload group. Do not interpret the configured value as a warehouse-wide cap or a billable capacity limit.

Check the queue status​

SHOW WORKLOAD GROUPS;

Inspect the intended cluster and group in the result. running_query_num is the current admitted-query count and waiting_query_num is the waiting-query count reported by the frontend handling the statement. These counts are queries, even when some queries request multiple slots.

To inspect queued queries across frontends:

SELECT workload_group_id,
query_id,
query_status,
queue_start_time
FROM information_schema.active_queries
WHERE query_status = 'queued'
ORDER BY workload_group_id, queue_start_time;

See ACTIVE_QUERIES for columns and visibility requirements.

Adjust queue limits​

For example, increase the queue capacity and wait limit without changing the concurrency limit:

ALTER WORKLOAD GROUP queue_group FOR analytics
PROPERTIES (
"max_queue_size" = "40",
"queue_timeout" = "10000"
);

A larger queue increases the amount of work waiting, and a longer timeout increases how long callers can remain blocked. Compare query latency and application retries before increasing these values.

Bypass the queue for administration​

For a diagnostic session that needs to bypass query admission, set:

SET bypass_workload_group = true;

This bypasses the queuing logic. It does not remove workload group resource limits. Restore normal admission when the diagnostic work finishes:

SET bypass_workload_group = false;

Use this setting sparingly during resource pressure. Additional admitted work can worsen the bottleneck.

Common errors​

SymptomCause and action
query waiting queue is fullNo admission slot or required resource is available, and the waiting queue is full. Reduce submitted concurrency, tune expensive queries, or review queue and cluster capacity.
query queue timeoutThe query did not receive admission before its queue or query timeout. Check resource pressure and running work before increasing timeouts.
A query slot count errorThe requested query_slot_count is invalid or exceeds the group's positive max_concurrency. Use a valid slot count or adjust the group.
The selected workload group cannot be found or usedCheck the current cluster, the group name, and the SQL user's USAGE privilege.

See also​

Ask AI