Hello Team, I am using starrocks `v3.4.5` in k8s d...
# questions-and-troubleshooting
a
Hello Team, I am using starrocks
v3.4.5
in k8s deployment using iceberg catalog for analytics (Shared Data Mode -> CN only). I am facing issues when trying to run regex queries which involve more data scanning. Getting the same spill issue
Copy code
ERROR 1064 (HY000): Memory of default_wg exceed limit. Pipeline Backend: starrocks-cn-0.starrocks-cn-search.traceable.svc.cluster.local, fragment: a48af6d2-8fad-11f0-b062-5a3646794132 Used: 11748494560, Limit: 11741366844. Mem usage has exceed the limit of query pool: BE:153558
I understand this issue should be solvable using spill and have read the multiple threads on the channel regarding the same but somehow even by enabling the configs spill is not happening. Here are the configs I have set:
Copy code
mysql> set global enable_spill = true;
Query OK, 0 rows affected (0.00 sec)

mysql> set global spill_mode  = 'force';
Query OK, 0 rows affected (0.00 sec)

mysql> set global pipeline_dop = 2;
Query OK, 0 rows affected (0.02 sec)

--trigger early spill
mysql> ALTER RESOURCE GROUP default_wg WITH (     'spill_mem_limit_threshold' = '20%' );
I have also set the CN conf as follows
Copy code
spill_local_storage_dir=/opt/starrocks/cn/spill
For the above location I have tried using an
emptyDir
,
PVC
and simple node storage as well but still I get the OOM issue. Any pointers on this? TIA
r
Some operators don't support memory spill. Can you share the query and the profile?
b
Try to add exec_mem_limit
a
@Robert Raharjo the query causing the issue has a
regexp
operator
query is simething like below
Copy code
SELECT * FROM <table> WHERE (customer_id = 'customer-id') AND ((((regexp(request_body, 'pair')) AND ((start_time_millis_ts >= '2025-09-03 10:14:11') AND (start_time_millis_ts < '2025-09-04 10:14:11'))) ORDER BY 1 DESC, start_time_millis DESC LIMIT 10;
I haven't taken the profile yet, let me see how to do that
> Try to add exec_mem_limit Will try this once
A follow up question. I am seeing the CN failure happening at the memory limit but at that time the actual memory consumption only seems to be half of it. An example of CN logs below:
Copy code
E20250915 07:22:07.462986 140281858823744 scan_operator.cpp:478] scan fragment 82e97e05-9204-11f0-9825-fab1d11951dd driver 4 Scan tasks error: Internal error: FileReader::get_next failed. reason = Memory limit exceeded: Memory of default_mv_wg exceed limit. read and decompress page Backend: starrocks-cn-0.starrocks-cn-search.traceable.svc.cluster.local, Used: 94287230360, Limit: 93930934762. Mem usage has exceed the limit of the resource group [default_mv_wg]. You can change the limit by modifying [mem_limit] of this group
be/src/formats/parquet/column_chunk_reader.cpp:167 CurrentThread::mem_tracker()->check_mem_limit("read and decompress page")
be/src/formats/parquet/column_chunk_reader.cpp:213 _read_and_decompress_page_data(compressed_size, uncompressed_size, true)
be/src/formats/parquet/column_chunk_reader.cpp:152 _parse_data_page()
be/src/formats/parquet/stored_column_reader.cpp:393 _reader->load_page()
be/src/formats/parquet/stored_column_reader.cpp:337 _lazy_skip_values(range.begin())
be/src/formats/parquet/group_reader.cpp:292 _column_readers[slot_id]->read_range(range, filter, (*chunk)->get_column_by_slot_id(slot_id))
be/src/formats/parquet/group_reader.cpp:218 value_or_err_L218, file = s3a://<file_chunk_path>
be/src/connector/hive_connector.cpp:777 _scanner->get_next(state, chunk)
Here its failing roughly at ~90GB. But actual memory consumption of the CN nodes is only ~45GB. Below screenshots confirm it
👀 3
@Kevin Cai you had some thoughts on this?
k
can you grep
Current memory statistics:
in CN.info around the time range, take a look what's the stats looked like.
a
yes I have those. They go all the way upto ~90gb
Copy code
I20250915 07:20:14.799925 140286380439104 daemon.cpp:159] Current memory statistics: process(496402040), query_pool(0), load(0), metadata(0), compaction(0), schema_change(0), page_cache(0), update(0), chunk_allocator(0), passthrough(0), clone(0), consistency(0), datacache(0), jit(0)
I20250915 07:20:59.812546 140286380439104 daemon.cpp:159] Current memory statistics: process(496411640), query_pool(0), load(0), metadata(0), compaction(0), schema_change(0), page_cache(0), update(0), chunk_allocator(0), passthrough(0), clone(0), consistency(0), datacache(0), jit(0)
I20250915 07:21:14.816346 140286380439104 daemon.cpp:159] Current memory statistics: process(69770179416), query_pool(69192249208), load(0), metadata(0), compaction(0), schema_change(0), page_cache(0), update(0), chunk_allocator(0), passthrough(0), clone(0), consistency(0), datacache(0), jit(0)
I20250915 07:21:29.821259 140286380439104 daemon.cpp:159] Current memory statistics: process(87371246024), query_pool(86757720008), load(0), metadata(0), compaction(0), schema_change(0), page_cache(0), update(0), chunk_allocator(0), passthrough(0), clone(0), consistency(0), datacache(0), jit(0)
I20250915 07:21:59.828548 140286380439104 daemon.cpp:159] Current memory statistics: process(90052352800), query_pool(89459778120), load(0), metadata(0), compaction(0), schema_change(0), page_cache(0), update(0), chunk_allocator(0), passthrough(0), clone(0), consistency(0), datacache(0), jit(0)
I20250915 07:22:14.832030 140286380439104 daemon.cpp:159] Current memory statistics: process(91319269064), query_pool(90733988896), load(0), metadata(0), compaction(0), schema_change(0), page_cache(0), update(0), chunk_allocator(0), passthrough(0), clone(0), consistency(0), datacache(0), jit(0)
I20250915 07:22:29.835451 140286380439104 daemon.cpp:159] Current memory statistics: process(92744065192), query_pool(92252509728), load(0), metadata(0), compaction(0), schema_change(0), page_cache(0), update(0), chunk_allocator(0), passthrough(0), clone(0), consistency(0), datacache(0), jit(0)
I can also rerun the tests to capture them again (might have missed a few logs here), but remember the pattern
k
the logs shown the memory was indeed full, how's the interval collected by the pod mem monitor? is it possible the mem increased too quick that the monitor did sample the peak usage?
a
I am actually running a test just as we speak. Let me share the results
Attached logs.
CPU and memory usage (I have kept only 2 CNs so that query takes longer) We see that the CN is seeing a usage of around 40gb but the container memory is ~20g
The pod memory (in grafana dashboard) is obtained using
container_memory_working_set_bytes
(standard memory metric for overall pod memory)
k
can you login the pod, and run
top -p {cn_pid}
take a look the stats of the memory for the process.
a
image.png
this is consistent with the dashboard (~22gb)
k
what's the starrocks version?
a
v3.4.5
I tried with multiple versions but getting mostly the same results, but can confirm again with the other versions if needed (tried 3.4.x)
k
a
not specifically, I have built my own dashboards based on the starrocks metrics. But I can plot something if that helps
k
can you run
curl "http://localhost:8040/mem_tracker?upper_level=4&type=query_pool"
inside the pod, need to get a detailed stats from the query pool
a
Previous query had finished, re ran it and this is for the one
k
what's the query looks like, from the last line, try to search
0427...
the query id from fe.log
a
There are 2 queries running concurrently (MV refresh query)
Copy code
CREATE MATERIALIZED VIEW IF NOT EXISTS internal_db.<table1> REFRESH DEFERRED MANUAL PROPERTIES ("replication_num" = "1") AS SELECT start_time_millis - (start_time_millis % 900000) AS view_col_0, count(*) AS view_col_1, 'dummy_col' AS dummy_alias
FROM <iceberg_table>
WHERE (customer_id = 'customer') AND ((regexp(request_body, 'paired')) AND ((start_time_millis_ts >= '2025-09-04 07:24:15') AND (start_time_millis_ts < '2025-09-10 07:24:15')))
GROUP BY 1 ORDER BY 1 ASC  LIMIT 1000;

CREATE MATERIALIZED VIEW IF NOT EXISTS internal_db.<table2> REFRESH DEFERRED MANUAL PROPERTIES ("replication_num" = "1") AS SELECT  view_col_0, view_col_1, view_col_2, view_col_3
FROM <iceberg_table>
WHERE (customer_id = 'customer') AND ((regexp(request_body, 'paired')) AND ((start_time_millis_ts >= '2025-09-04 07:24:15') AND (start_time_millis_ts < '2025-09-10 07:24:15'))) ORDER BY 10 DESC  LIMIT 50;
I am doing a
REFRESH MV WITH SYNC MODE
for both the queries
k
compare the
query_pool
from the "Current memory statistics" logline and the mem_tracker http interface, are they about equal at the same timepoint?
a
The
query_pool
log line is higher
k
can you take a snapshot of the query_pool from memtracker and from the logline, as well as the mem info from top -p of the cn process inside the pod?
a
image.png,image.png
c
@Arun Dhingra just wondering, did you try the same query with a simple
LIKE '%pair%'
predicate? I'm wondering if
regexp
brings in memory overhead or even a possible leak.
a
These 2 or more interesting, my observation has been that
Current Memory log
>
Query pool Stats
>>
actual memory from top command or container memory
The difference between
Current Memory log
and
Query pool Stats
is not a lot but they are quite high compared
actual memory
The difference is somewhere between 1.5 to ~2x
@Arun Dhingra just wondering, did you try the same query with a simple
LIKE '%pair%'
predicate? I'm wondering if
regexp
brings in memory overhead or even a possible leak.
This particular query is simple and can be replaced with
LIKE
but in general there are actual regex queries, using this simple regex here just for testing
r
To get the query profile you should run set enable_profile = true; Then go to the queries dashboard http//&lt;fe ip&gt;<http-port> https://docs.starrocks.io/docs/best_practices/query_tuning/query_profile_overview/
k
will the mem usage dropped when you stopped the two MV async refresh?
a
will the mem usage dropped when you stopped the two MV async refresh?
I am assuming to meant to ask if the memory usage went down after the refresh finished? yes
k
ok. so to be accurate, when the mv is refreshing, the statistics from the memtracker and from the log is doubled than the actual mem usage from the process RSS, once the refresh done, the mem usage dropped, and the numbers about to match each other. Right?
a
yes... but is mostly happening when the query is containing a
REGEXP
operator... when
REGEXP
is not present it is mostly similar (in rare scenarios I do see query_pool log showing a high memory but that I guess is transient)
k
would you please open an issue on github and paste the detailed info about the memory numbers from top, log and mem_tracker? will have someone else take a look.
a
sure will do that. Really appreciate the effort here @Kevin Cai
just a general question, is
REGEXP
not very performant in starrocks?
k
it depends. But to me, the current issue is the inaccurate mem stats, which shall have nothing to do with the query performance.
a
yes that makes sense, but my question is more in general where in the CN memory can continue to grow unbounded (ideally we would want to memory to be stable and let the query be slow)
👌 1
@Kevin Cai have raised a GH issue https://github.com/StarRocks/starrocks/issues/63259
please let me know if you feel any other detail is missing
👌 1