Hi team, I'm facing an issue where the query_pool ...
# questions-and-troubleshooting
c
Hi team, I'm facing an issue where the query_pool in the mem_tracker does not release memory even after the query has finished. The corresponding fragment does not appear in the BE log, yet memory is still being held. I'm using shared-nothing data mode on StarRocks - vers: 3.5.1. This behavior appears similar to a previously reported issue on GitHub: https://github.com/StarRocks/starrocks/issues/53155 However, that case was reported under CN node in shared-data mode, version 3.3.2
k
may not be the same. Are you able to get the logs of the fragment that may be marked as finished after hours, so we can take further look what may cause the delay releasing of the fragments in BE process
c
I can't find any logs related to the fragment that caused the hang. But here's the logs related to that fragment.
Copy code
[chienpm@sandbox-22:/build/starrock/be/log]$ grep  '895dc3ba-e417-41a8-b4f1-1dcaa9ca1963' be.INFO
W20250728 15:29:34.269014 140636783113984 fragment_context.cpp:200] [Driver] Canceled, query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963, instance_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe, reason=FragmentContext(id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe) cancelled by close_scanner
W20250728 16:29:31.342026 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
W20250728 16:29:31.342126 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
W20250728 16:29:31.342157 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
W20250728 16:29:31.342172 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
W20250728 16:29:31.342186 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
W20250728 16:29:31.342200 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
W20250728 16:29:31.342214 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
W20250728 16:29:31.342239 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
W20250728 16:29:31.342254 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
W20250728 16:29:31.342268 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
W20250728 16:29:31.342288 140644407904000 pipeline_driver_poller.cpp:96] [Driver] Timeout query_id=895dc3ba-e417-41a8-b4f1-1dcaa9ca1963 fragment_id=074dd6d9-3ee9-69fa-a94f-2a58b3af9fbe driver=driver_0_1 addr=0x7fe8a5fa8d10, status=PENDING_FINISH, operator-chain: [olap_scan_0_0x7fe8a59c6010(X) { full:false iostasks:0 has_active:false num_chunks:0 morsel:fixed_morsel_queue empty:false has_output:false} -> memory_scratch_sink_-1_0x7fe8a5fa8110(X)]
k
are you trying use flink connector or spark connector to read data from SR directly?
c
I'm using spark connector
k
should be an known issue with the connector, you can set a shorter timeout to let the fragments expired automatically.
c
yes, but I observed that some query fragments remained active for 3 -4 days.
k
@Pengfei Li can you check if this is the same one as https://github.com/StarRocks/starrocks-connector-for-apache-flink/pull/441
🙌 1
p
@Chien Pham Minh What’s the status of spark job? Could you post the spark connector version, configurations?
c
The Spark job status is FINISHED - SUCCEEDED and here's my conf:
Copy code
sudo -u cdpcore /bin/sh /build/iceberg/spark-3.5.4-bin-hadoop3/bin/spark-submit \
--class "com.at.audience.spark.LoadTestStarRock" \
--name "LoadTestStarRockWriteRandomData" \
--master yarn \
--deploy-mode cluster \
--queue llap \
--num-executors 2 \
--executor-memory 4g \
--executor-cores 1 \
--driver-memory 1g \
--jars "/build/spark_jar/spark3/lib/spark-sql_2.12-3.5.4.jar,/build/spark_jar/spark3/lib/starrocks-spark-connector-3.5_2.12-1.1.3.jar,/build/spark_jar/chienpm/spark3/lib/mysql-connector-java-8.0.29.jar" \
/build/cdp/core_jobs/load_test_starrock/be-jobs-iceberg-1.0.jar
p
What’s the connector configurations? Could you provide spark driver and executor logs?
c
spark_full_logs.log
Copy code
val df = spark.read.format("starrocks")
        .option("starrocks.table.identifier", "test.customer_v2")
        .option("starrocks.fenodes", "localhost:7030")
        .option("starrocks.fe.jdbc.url", "jdbc:mysql://localhost:9030")
        .option("starrocks.user", "core")
        .option("starrocks.password", "Core@2025")
        .option("starrocks.columns", selectedColumns.mkString(","))
        .load()
        .select(selectedColumns.head, selectedColumns.tail: _*)
        .limit(numRows)
Copy code
transformedDF.write.format("starrocks")
        .option("starrocks.table.identifier", "test.customer_v2")
        .option("starrocks.fenodes", "localhost:7030")
        .option("starrocks.fe.jdbc.url", "jdbc:mysql://localhost:9030")
        .option("starrocks.user", "core")
        .option("starrocks.password", "Core@2025")
        .option("starrocks.write.properties.partial_update", "true")
        .option("starrocks.columns", starrocksColumns)
        .mode("append")
        .save()
here's the info
👌 1
p
@Chien Pham Minh The spark job you sent was started at about
17:43:46
, but from BE log, the fragment appeared at
15:29:34
, so the above spark job should not be the one caused the problem. Could you check it?
c
Sorry, I sent the wrong log earlier. Let me re-check and get you the correct one. Thanks for pointing it out!
here's the correct one
👌 1
p
I don’t find any exception at the spark side. Each opened connection to StarRocks has been closed. @Chien Pham Minh Is this problem reproducible?
c
Yes, the issue is reproducible. I have already restarted the BE node, but the memory leak still occurs with a different Spark job.
p
Could you send me the be log?
c
should i send the full log?
p
yes, and please also take a screenshot showing memory usage details, including non-released queries/fragments
🙌 1
c
I have run a new spark job for shorter log, the image with grep is query id and the other with null is fragment id
👍 1
For more information, the query ID timed out after 1 hour but still retained memory on the BE node.
p
1. emm, BE log did not include the timeout query in the image. The time did not match 2. could you get a pstack of be when the problem happens 2. could you provide the cluster information and the table schema? I will try to reproduce it
c
1. Yes, the first 6 files are logs for one job. The last 2 images are from a different job — I just included them to give additional context about the timeout timing. 2. I try to get permission to use pstack from system team. 3. And here is the info:
Hi @Pengfei Li, the code cause leak mem:
Copy code
val df = spark.read.format("starrocks")
  .option("starrocks.table.identifier", tableName)
  .option("starrocks.fenodes", "localhost:7030")
  .option("starrocks.fe.jdbc.url", "jdbc:mysql://localhost:9030")
  .option("starrocks.user", "core")
  .option("starrocks.password", "Core@2025")
  .option("starrocks.columns", selectedColumns.mkString(","))
  .load()
  .select(selectedColumns.head, selectedColumns.tail: _*)
  .limit(numRows)
df.count()
and I can avoid that by using:
Copy code
val df = spark.read.format("starrocks")
  .option("starrocks.table.identifier", tableName)
  .option("starrocks.fenodes", "localhost:7030")
  .option("starrocks.fe.jdbc.url", "jdbc:mysql://localhost:9030")
  .option("starrocks.user", "core")
  .option("starrocks.password", "Core@2025")
  .option("starrocks.columns", selectedColumns.mkString(","))
  .option("query", s"SELECT ${selectedColumns.mkString(",")} FROM tableName LIMIT $numRows")
  .load()

df.count()
I think it would help