Add memory tracking and cap to query consolidator#804
Draft
tanjinx wants to merge 1 commit intoslack-22.0from
Draft
Add memory tracking and cap to query consolidator#804tanjinx wants to merge 1 commit intoslack-22.0from
tanjinx wants to merge 1 commit intoslack-22.0from
Conversation
Track memory usage of pending results in the consolidator using atomic int64, and add a --consolidator-memory-cap flag to bypass consolidation when memory exceeds the configured threshold (default 0 = unlimited). Exposes a ConsolidatorMemoryUsage gauge metric for observability. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> Signed-off-by: Tanjin Xu <tanjin.xu@slack-corp.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Track memory usage of pending results in the consolidator using atomic int64, and add a --consolidator-memory-cap flag to bypass consolidation when memory exceeds the configured threshold (default 0 = unlimited). Exposes a ConsolidatorMemoryUsage gauge metric for observability.
Description
What's this?
Adds memory tracking to the query consolidator so we can observe and bound how much memory is held in pending results. When many distinct queries are in-flight with large results, the consolidator can cause unbounded memory growth -- this gives us a cap to gracefully degrade by bypassing consolidation.
How it works
SetResultadds the result'sCachedSize,Broadcastsubtracts it--consolidator-memory-capflag (default 0 = unlimited). When exceeded, new queries skip consolidation and execute independently (fallthrough, never rejects)ConsolidatorMemoryUsagegauge metric for observabilityFiles changed
go/sync2/consolidator.go-- core memory tracking (memoryfield,Memory()interface method)go/sync2/fake_consolidator.go-- updated fake to satisfy interfacego/sync2/consolidator_test.go-- three new tests (basic, nil result, concurrent)go/vt/vttablet/tabletserver/tabletenv/config.go-- new config field + flaggo/vt/vttablet/tabletserver/query_engine.go-- gauge metric registrationgo/vt/vttablet/tabletserver/query_executor.go-- memory cap check inexecSelect()Most of this was written by Claude Code - I just provided direction.
Related Issue(s)
Checklist
Deployment Notes
AI Disclosure