-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: OOM risk of EXPLAIN ANALYZE (DEBUG) of statement with large lookup or index join #103358
Comments
Nice find!
Max memory usage reported by the bundle only includes the execution statistics collected during the query run about the memory usage of operators in the plan, but we never include the auxiliary stuff like trace data unmarshalling in that number, so it's expected for this memory to not be included into the diagram. We did add accounting for |
If I'm reading the comments here cockroach/pkg/util/tracing/tracer.go Lines 53 to 57 in 2b66e5e
right, then it's expected that the log messages for a single trace could take up to 256MB in size, so it appears that we're not respecting these two limits (or perhaps there is additional overhead due to serialization / deserialization logs into protobuf). We might need some guidance from Obs Infra to know whether this behavior is expected or not, cc @dhartunian @abarganier |
From triage meeting:
|
Could we benefit here by adding a pool for |
I'm not sure if we have a precedent for this (we'd need to modify how the protobuf generated code is generated, or perhaps disable generation of However, I'm a bit worried about sync-pooling some of these large |
I'm just driving by, but are we talking about the right problem? I doubt anyone on KV would object to significantly clamping down on this log statement. We should never be logging unbounded amounts of data. It's difficult to prevent creation of large log messages, but perhaps via logging telemetry (sentry?) we could highlight locations for which a message of >256kb (arbitrary threshold) was ever seen, and at least take measures after the fact. |
It looks like that log message should already be truncated to roughly 1KiB, and IIUC the problem is that we have too many log messages which add up. |
At the end of statement diagnostics bundle collection of a query with a large lookup or index join, there can be a large spike in memory usage. Sometimes this is enough to OOM a node. Here's a demonstration using a real cluster:
Here's how that looked in the metrics:
Even though the bundle said max memory usage was 67 MiB, we actually saw a spike > 1 GiB.
This is very similar to #90739 and may even be the same root cause (verbose tracing) but I wanted to document the spike in memory usage. We should try to fix this spike even if statement bundle collection takes longer than normal execution.
I believe the spike in memory on the gateway node is due to unmarshaling of this log message in traces:
cockroach/pkg/kv/kvserver/replica_evaluate.go
Lines 550 to 551 in 190aa54
I have reproduced this on both v23.1.0 and v21.2.17.
Jira issue: CRDB-27960
The text was updated successfully, but these errors were encountered: