High memory usage caused by CQ

hello:
I have an very strange problem.
my situation:
os: centos-7.1
kernel: 3.10.0-327.28.2.el7.x86_64 #1 SMP Wed Aug 3 11:11:39 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
influxdb: 1.1.0 x86_64
cpu: 4 processor
memory: 4G
Now i have a CQ strategy that run every 6h and it finished in 2s, But my influxdb memory property(rss) rise about 100% last 5m at the same time.
My CQ: meter_speed_agg_6h CREATE CONTINUOUS QUERY meter_speed_agg_6h ON aaa RESAMPLE EVERY 6h FOR 12h BEGIN SELECT mean(mean_byte) AS mean_byte, mean(mean_pk) AS mean_pk, max(max_byte) AS max_byte, max(max_pk) AS max_pk INTO aaa.autogen.meter_speed_6h FROM bbb.autogen.meter_speed GROUP BY id, name, dev, time(6h) END
My question: Why the memory property(rss) rise about 100%, and last about 5m?

Influxdb runs with 1G memory(rss) at normal time, when the CQ runs it will ocuppied with 2G memory(rss).
Firstly i thought maybe the query trigger the high usage of memory, but the query only spend 2s at mostly.
So can someone explain it?

The system/db stats if enabled should be able to validate if the query is causing this spike in usage. But in my experience the behavior you are seeing is correct. Any query on the database fields is a memory operation; it will load all the data and perform the required operation. The five minute delay that you are seeing with memory cleanup; it is due to the Garbage Collector clearing the memory and making it back available to the system.

Thanks for your reply, buddy.
But i run with the query statement: SELECT mean(mean_byte) AS mean_byte, mean(mean_pk) AS mean_pk, max(max_byte) AS max_byte, max(max_pk) AS max_pk INTO aaa.autogen.meter_speed_6h FROM bbb.autogen.meter_speed where time > now() - 12h GROUP BY id, name, dev, time(6h).
The memory usage looks like normal, So how to explain it?
BTW, how to use show stats to validate the query?

following is my query statement changes after the execution:
name: runtime
Alloc Frees HeapAlloc HeapIdle HeapInUse HeapObjects HeapReleased HeapSys Lookups Mallocs NumGC NumGoroutine PauseTotalNs Sys TotalAlloc


202211504 16250450015 202211504 1461878784 266010624 3286464 1110212608 1727889408 958209 16253736479 9014 112 13401657641 1830049992 1417027728704

name: runtime
Alloc Frees HeapAlloc HeapIdle HeapInUse HeapObjects HeapReleased HeapSys Lookups Mallocs NumGC NumGoroutine PauseTotalNs Sys TotalAlloc


264529280 16253162614 264529280 1393729536 334127104 3607337 1110212608 1727856640 958331 16256769951 9016 112 13403255257 1830049992 1417404931464

You can take a heap table real time insight by using the below:

curl -o heap.txt http://localhost:8086/debug/pprof/heap?debug=1

However the further debugging you may need to have someone from the Engg team investigate this.

1 Like