<@U0A71G31CDV>, I am getting this error when runni...
# questions-and-troubleshooting
k
@Rocky, I am getting this error when running a complicated query on starrocks - io.cloudbeaver.DBWebException: Error executing query: SQL Error [1064] [42000]: Memory of query_pool exceed limit. Pipeline Backend: starrocks-cn-6.starrocks-cn-search.trino.svc.cluster.local, fragment: 01a22c74-fd85-7ef4-86a2-f6b9730f4618 Used: 37579825976, Limit: 37572373904. Mem usage has exceed the limit of query pool: BE:51570006 at io.cloudbeaver.service.sql.WebSQLProcessor.processQuery(WebSQLProcessor.java:273) at io.cloudbeaver.service.sql.impl.WebServiceSQL$2.run(WebServiceSQL.java:472) at io.cloudbeaver.model.session.WebSession$1.run(WebSession.java:593) at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:119) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: org.jkiss.dbeaver.model.sql.DBSQLException: SQL Error [1064] [42000]: Memory of query_pool exceed limit. Pipeline Backend: starrocks-cn-6.starrocks-cn-search.trino.svc.cluster.local, fragment: 01a22c74-fd85-7ef4-86a2-f6b9730f4618 Used: 37579825976, Limit: 37572373904. Mem usage has exceed the limit of query pool: BE:51570006 at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:130) at io.cloudbeaver.service.sql.WebSQLProcessor.lambda$1(WebSQLProcessor.java:257) at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:189) at io.cloudbeaver.service.sql.WebSQLProcessor.processQuery(WebSQLProcessor.java:214) ... 4 more Caused by: java.sql.SQLSyntaxErrorException: Memory of query_pool exceed limit. Pipeline Backend: starrocks-cn-6.starrocks-cn-search.trino.svc.cluster.local, fragment: 01a22c74-fd85-7ef4-86a2-f6b9730f4618 Used: 37579825976, Limit: 37572373904. Mem usage has exceed the limit of query pool: BE:51570006 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:121) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:767) at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:652) at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.execute(JDBCStatementImpl.java:344) at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:128) ... 7 more
r
What the error means This is the query pool limit on a single backend node (here
starrocks-cn-6
, a shared-data CN), not the per-query limit. All queries running on that node together went over the pool's cap: • The pool limit is the BE/CN config
query_max_memory_limit_percent
(default
90
= 90% of the node's process memory limit). It is not mutable at runtime — it's read from the config file. • Your numbers:
Limit: 37,572,373,904
B ≈ 35.0 GiB,
Used: 37,579,825,976
B ≈ 35.0 GiB. Taking the defaults (
query_max_memory_limit_percent=90
,
mem_limit=90%
), that implies a process limit of ~38.9 GiB and roughly a ~46 GB machine — so if the CN is a bigger node, someone has already changed one of these settings. • Practical consequence: raising
query_mem_limit
will not help here. That variable limits one query on one node (error text: "exceed the limit of single query"). Here the shared pool is full, so the pool tracker rejected the allocation. Diagnose first (on the failing CN)
Copy code
bash
curl -s http://<cn_host>:<be_http_port>/mem_tracker          # see which child of `process` is big
curl -s "http://<cn_host>:<be_http_port>/mem_tracker?type=query_pool&upper_level=3"  # which queries
curl -s http://<cn_host>:<be_http_port>/metrics | grep -E "^starrocks_be_(query_pool|.*)_mem_bytes"
If
query_pool
is genuinely the large child, it's queries; if something else (compaction, page cache/`datacache_mem_size`, load) is large, the query is just the one that tripped the check. Options, roughly in order of preference 1. Reduce the query's memory footprint (docs' own recommendation for this exact message is "Optimize the SQL"): check for a huge hash join build side or high-cardinality `GROUP BY`/`DISTINCT`/window, add aggressive partition/`WHERE` pruning, avoid
SELECT *
over wide tables, collect statistics so the join order/distribution is sensible. 2. Enable spilling so aggregate/sort/hash-join/CTE operators write to disk under memory pressure:
Copy code
sql
   -- CN conf: spill_local_storage_dir=/<dir>   (static, restart required; use a disk separate from data)
   SET enable_spill = true;
   SET spill_mode = 'auto';           -- or 'force' to guarantee it
   SET query_timeout = <bigger>;      -- spilling typically costs ~10x latency
Caveat: spilling can't release expression-evaluation memory, and the CN's spill dir is shared across concurrent queries. 3. Cap the query itself rather than the pool:
SET query_mem_limit = <bytes>
(per query, per node) or a resource group
big_query_mem_limit
/
mem_limit
. Note a query with a hard cap gets killed with a different error rather than queued. 4. Reduce concurrency / queue instead of failing:
SET GLOBAL query_queue_mem_used_pct_limit = 0.8
plus a non-zero
query_mem_limit
(the docs explicitly say to set both — the FE logs a warning if you set the % limit while the global
query_mem_limit
is still 0), and/or
query_queue_concurrency_limit
. The docs recommend an admission limit between 0.75 and 0.85. 5. Give the pool more headroom (last resort, and a config change + restart): raise
query_max_memory_limit_percent
(or
mem_limit
). Beware that in Kubernetes this only helps if the container's memory limit is above
mem_limit
, otherwise you trade a clean rejection for an OOM kill. One thing worth checking before tuning: whether this reproduces on a second run. There are known bugs where this exact message appears on the second execution of a
GROUP BY
with a selective
HAVING
(fixed in 4.1.6 / 4.0.16) and with `INTERSECT`/`EXCEPT` on very wide rows (same releases). If you're on an older patch of 3.5/4.0/4.1, check whether your workload matches — in that case upgrading is the fix. If you can paste the failing SQL's rough shape (joins, aggregates, table sizes) plus your StarRocks version, I can narrow it down further; otherwise the
mem_tracker
output is the fastest next step. References