Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uptopk and bottomk queries with large k cause OOM panic #3973
Comments
roganartu
changed the title
`topk` and `bottomk` queries with large `k` causes OOM panic
topk and bottomk queries with large k causes OOM panic
Mar 15, 2018
This comment has been minimized.
This comment has been minimized.
|
A simpler approach would be to use the smaller of k and the size of the input vector. |
roganartu
changed the title
topk and bottomk queries with large k causes OOM panic
topk and bottomk queries with large k cause OOM panic
Mar 15, 2018
davbo
referenced this issue
Apr 15, 2018
Merged
Fix OOM when a large K is used in topk queries #4087
davbo
added a commit
to davbo/prometheus
that referenced
this issue
Apr 15, 2018
brian-brazil
closed this
in
#4087
Apr 16, 2018
brian-brazil
added a commit
that referenced
this issue
Apr 16, 2018
gouthamve
added a commit
to gouthamve/prometheus
that referenced
this issue
Aug 1, 2018
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 22, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
lock
bot
locked and limited conversation to collaborators
Mar 22, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
roganartu commentedMar 15, 2018
Query
Expected
Actual
Prometheus spins 100% on a core for a short period then OOM panics. This happens with lower values of
kfor queries with higher label cardinality.Note: Increasing
kby appending further digits results in short-circuiting with no OOM, so it seems there's at least some protection from this already, though the error message suggests this comes from the Go runtime not Prometheus itself:Use Case
Grafana graph with a limit variable that is passed as
k. To have anAlloption that at least looks like it includes all, you need to provide an arbitrarily highk. I'm sure there are others though, and in any case I suspect most users would not expect increasingkto continue increasing memory consumption past the number of available samples.Cause
Calling
make(..., k)for each set of unique labels:prometheus/promql/engine.go
Lines 1327 to 1339 in e87c6c8
Proposed Fix
For
kover some threshold exponentially grow theVectorup to a maximumkinstead of statically allocating all ofkupfront.