Hi all,
I’m new to the forum so let me first introduce myself:
My name is Pim and I’m a software enthousiast from the Netherlands. I’m using Prometheus for one of my hobby projects to measure indoor climate like air quality and temperature etc. Professionally I’m a java back-end developer mainly in the fintech industry.
I’m not sure if this post belongs here or in the general/support channel, but since it applies to Prometheus server, I opted for this location.
I’m running Prometheus in a docker container along with my Java Spring Boot app, Postgres and Grafana on a Raspberry Pi 4 with 4GB of RAM. I’m running Raspberry Pi OS (32bit). I was running Prometheus 2.25.2 and tried to downgrade to 2.24.x but to no avail.
My problem is that my prometheus server started crashing lately during the compacting process. The logs mention a failure of allocating memory and a file already being closed. For a more detailed logs snippet, see below. It seems it is requesting to allocate 128MB of memory, and I have plenty of memory I suppose (2424MB available and 642MB free). So I’m not really sure why this happens.
I have about 1 year of history. I started with a couple of sensors but it grew up to about 930 series today.
I hope to get some pointers how to improve my setup so it stops crashing.
Here is a snapshot of a Prometheus dashboard in Grafana of the past 7 days:
https://snapshot.raintank.io/dashboard/snapshot/odeWxReUZ7fHGlE0bkQkAq0Y3Nb0qYDx
Log snippet:
level=info ts=2021-04-17T19:55:23.747Z caller=compact.go:507 component=tsdb msg=“write block” mint=1618678485953 maxt=1618682400000 ulid=01F3GPDTRF3RGYPE28T7TS0J6M duration=2.003752952s
level=info ts=2021-04-17T19:55:23.795Z caller=head.go:824 component=tsdb msg=“Head GC completed” duration=17.450022ms
level=info ts=2021-04-17T19:55:24.236Z caller=compact.go:448 component=tsdb msg=“compact blocks” count=2 mint=1618649310953 maxt=1618660800000 ulid=01F3GPDWT1HM69QWR09MPZD7H0 sources="[01F3FTJDBCCMT9A9QV47A9GDB7 01F3FYNASWMA2MBPM357FCV4CV]" duration=394.930521ms
level=info ts=2021-04-17T19:55:24.255Z caller=db.go:1191 component=tsdb msg=“Deleting obsolete block” block=01F3FYNASWMA2MBPM357FCV4CV
level=info ts=2021-04-17T19:55:24.267Z caller=db.go:1191 component=tsdb msg=“Deleting obsolete block” block=01F3FTJDBCCMT9A9QV47A9GDB7
level=info ts=2021-04-17T21:00:46.229Z caller=compact.go:507 component=tsdb msg=“write block” mint=1618682421670 maxt=1618689600000 ulid=01F3GT5K128HRMKAHTS0820AZ9 duration=242.687879ms
level=info ts=2021-04-17T21:00:46.251Z caller=head.go:824 component=tsdb msg=“Head GC completed” duration=7.452444ms
level=error ts=2021-04-17T21:00:46.284Z caller=db.go:745 component=tsdb msg=“compaction failed” err="compact head: head memory truncate: truncate chunks.HeadReadWriter: mmap, size 134217728: cannot allocate memory"
level=info ts=2021-04-17T21:01:48.703Z caller=compact.go:448 component=tsdb msg=“compact blocks” count=2 mint=1618660800000 maxt=1618682400000 ulid=01F3GT7FWZN8T2AQW3A1AF7FX8 sources="[01F3GEGTAWMYRXNPXATGQJVFEP 01F3GPDTRF3RGYPE28T7TS0J6M]" duration=384.301167ms
level=info ts=2021-04-17T21:01:48.721Z caller=db.go:1191 component=tsdb msg=“Deleting obsolete block” block=01F3GPDTRF3RGYPE28T7TS0J6M
level=info ts=2021-04-17T21:01:48.734Z caller=db.go:1191 component=tsdb msg=“Deleting obsolete block” block=01F3GEGTAWMYRXNPXATGQJVFEP
level=info ts=2021-04-17T23:00:46.237Z caller=compact.go:507 component=tsdb msg=“write block” mint=1618689621670 maxt=1618696800000 ulid=01F3H11A8Z5CV95JQPBSNSHKPG duration=253.839075ms
level=info ts=2021-04-17T23:00:46.259Z caller=head.go:824 component=tsdb msg=“Head GC completed” duration=7.374657ms
level=error ts=2021-04-17T23:00:46.259Z caller=db.go:745 component=tsdb msg=“compaction failed” err=“compact head: head memory truncate: truncate chunks.HeadReadWriter: write /prometheus/chunks_head/001838: file already closed”
panic: write /prometheus/chunks_head/001838: file already closed
goroutine 428 [running]:
github_com/prometheus/prometheus/tsdb.(*memSeries).mmapCurrentHeadChunk(0x5ae9600, 0x5356240)
/app/tsdb/head.go:2046 +0x228
github_com/prometheus/prometheus/tsdb.(*memSeries).cutNewHeadChunk(0x5ae9600, 0xe24738a6, 0x178, 0x5356240, 0x0)
/app/tsdb/head.go:2017 +0x24
github_com/prometheus/prometheus/tsdb.(*memSeries).append(0x5ae9600, 0xe24738a6, 0x178, 0xba5e353f, 0x40d56ee1, 0x2dc, 0x0, 0x5356240, 0x17ebcac)
/app/tsdb/head.go:2173 +0x3a0
github_com/prometheus/prometheus/tsdb.(*headAppender).Commit(0x5c216e0, 0x0, 0x0)
/app/tsdb/head.go:1265 +0x208
github_com/prometheus/prometheus/tsdb.dbAppender.Commit(0x257b918, 0x5c216e0, 0x5174480, 0x0, 0x67f1c4da)
/app/tsdb/db.go:773 +0x24
github_com/prometheus/prometheus/storage.(*fanoutAppender).Commit(0x6114fc0, 0x4b71555, 0x0)
/app/storage/fanout.go:174 +0x28
github_com/prometheus/prometheus/scrape.(*scrapeLoop).scrapeAndReport.func1(0x5ca9d90, 0x6641d98, 0x5262180)
/app/scrape/scrape.go:1086 +0x38
github_com/prometheus/prometheus/scrape.(*scrapeLoop).scrapeAndReport(0x5262180, 0xf8475800, 0xd, 0x540be400, 0x2, 0x67f6334f, 0xc016fb76, 0xb6ca72d7, 0x13e8, 0x33ecf78, …)
/app/scrape/scrape.go:1153 +0x748
github_com/prometheus/prometheus/scrape.(*scrapeLoop).run(0x5262180, 0xf8475800, 0xd, 0x540be400, 0x2, 0x0)
/app/scrape/scrape.go:1039 +0x29c
created by github_com/prometheus/prometheus/scrape.(*scrapePool).sync
/app/scrape/scrape.go:510 +0x728