sql: deflake TestStreamerTightBudget by fixing the streamer's initial estimate#171294
Draft
ZhouXing19 wants to merge 1 commit into
Draft
sql: deflake TestStreamerTightBudget by fixing the streamer's initial estimate#171294ZhouXing19 wants to merge 1 commit into
ZhouXing19 wants to merge 1 commit into
Conversation
… estimate TestStreamerTightBudget gives the Streamer a budget so tight that a single 1 MiB result puts it in debt, and asserts that peak memory usage stays around the expected ~2 MiB (1 MiB held by the Streamer, 1 MiB copied into the ColIndexJoin's columnar batch). The assertion flaked, observing usage as high as 4.6 MiB. The cause is the Streamer's cold initial response-size estimate. With no stats on the test table, the Streamer starts from its 1 KiB default estimate and issues all five lookup requests eagerly on the first pass. Eager (non-head-of-line) requests are sent with AllowEmpty=true, so when a 1 MiB blob exceeds the tiny TargetBytes the KV layer returns an empty response with a resume span, and the Streamer re-issues it. For five rows this produces nine KV gRPC calls (five eager + four resumes) rather than five. During that eager/resume churn, multiple full responses can transiently be held at once under unfavorable goroutine scheduling, pushing peak memory well above 2 MiB and tripping the assertion. Give the Streamer an accurate initial estimate (the blob size) via the sql.distsql.streamer.initial_avg_response_size cluster setting. The first head-of-line request then exhausts the budget on its own, so no eager requests are issued and the Streamer deterministically keeps a single request in progress (five KV gRPC calls, no resumes) - exactly the behavior this test means to verify. In production this estimate is supplied by optimizer stats. A SucceedsSoon guard waits for the cluster setting to propagate before the measured query runs. Verified with 300 stress runs; the measured usage is a stable 2.1 MiB. Fixes: cockroachdb#170853 Epic: none Release note: None Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Member
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.
TestStreamerTightBudget gives the Streamer a budget so tight that a
single 1 MiB result puts it in debt, and asserts that peak memory usage
stays around the expected ~2 MiB. The assertion flaked, observing usage
as high as 4.6 MiB.
The cause is the Streamer's cold initial response-size estimate. With no
stats on the test table, the Streamer starts from its 1 KiB default
estimate and issues all five lookup requests eagerly on the first pass.
Eager (non-head-of-line) requests are sent with
AllowEmpty=true, sowhen a 1 MiB blob exceeds the tiny
TargetBytesthe KV layer returns anempty response with a resume span, and the Streamer re-issues it. For
five rows this produces nine KV gRPC calls (five eager + four resumes)
rather than five — matching the "KV gRPC calls: 9" in the failure. During
that eager/resume churn, multiple full responses can transiently be held
at once under unfavorable goroutine scheduling, pushing peak memory well
above 2 MiB and tripping the assertion.
This gives the Streamer an accurate initial estimate (the blob size) via
the
sql.distsql.streamer.initial_avg_response_sizecluster setting. Thefirst head-of-line request then exhausts the budget on its own, so no
eager requests are issued and the Streamer deterministically keeps a
single request in progress (five KV gRPC calls, no resumes) — exactly the
behavior this test means to verify. In production this estimate is
supplied by optimizer stats.
Verified with 300 stress runs; measured usage is a stable 2.1 MiB.
Fixes: #170853
Epic: none
Release note: None
🤖 Generated with Claude Code