Skip to content

test(hashbuild): verify broadcast budget fails closed - #26638

Merged
XuPeng-SH merged 10 commits into
mainfrom
test/issue-25782-broadcast-budget-validation
Aug 3, 2026
Merged

XuPeng-SH merged 10 commits into
mainfrom
test/issue-25782-broadcast-budget-validation

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Validates the Phase 0 broadcast HashBuild safety contract from #26563.

  • adds a SQL-protocol regression retaining the [Bug]: HashBuild can bypass spill and trigger system OOM during large hash table growth #25782 grouped build-side aggregate and parallel low-NDV broadcast LEFT JOIN (max_dop = 2) under a 1 MiB hard HashBuild budget;
  • holds NDV and physical topology constant while changing only build cardinality between the admitted and rejected cases;
  • verifies the admitted control returns the exact joined payload, not merely a row count;
  • verifies terminal MySQL OOM code/state before any result set, no broadcast spill, and post-failure CN health;
  • exercises one real HashBuild with JoinMapRefCnt = 2 and two real HashJoin consumers on child processes, proving both receive the same terminal error before probe input and emit no partial output;
  • verifies no spill owner is created and memory, spill-disk, spill-FD, and mpool accounting return to zero after cleanup.

Invariant

A resident-only broadcast/shared JoinMap never becomes a spill topology. If its build cannot be admitted under the hard budget, it publishes one controlled terminal error to every consumer before probe input and releases all owned accounting.

Validation

  • focused SQL regression: TestIssue25782BroadcastHashBuildFailsClosedUnderHardBudget;
  • focused producer lifecycle regression: TestBroadcastBudgetFailurePublishesTerminalAndCleansBudget;
  • focused real-consumer regression: TestBroadcastBudgetFailureUnblocksParallelHashJoinConsumers;
  • full owning packages: pkg/sql/colexec/hashbuild, pkg/sql/colexec/hashjoin, and pkg/tests/issues;
  • race: real-consumer regression 100 times and the full pkg/sql/colexec/hashjoin package;
  • package-scoped go list, go build, go vet, and golangci-lint (0 issues).

Non-goals

No production spill protocol, planner policy, threshold-unit behavior, storage format, or hot path is changed.

Refs #25782
Part of #26563

@XuPeng-SH
XuPeng-SH requested a review from aunjgr as a code owner August 3, 2026 09:29
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Aug 3, 2026

@ck89119 ck89119 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: the current tests pass, but this exact head still does not close two Phase 0 acceptance paths claimed by the PR.

[P1] pkg/tests/issues/issue_25782_broadcast_budget_test.go:108-109 uses a plain table LEFT JOIN, not the #25782-like grouped-subquery/LEFT JOIN topology explicitly required by Phase 0 in #26563. The aggregate child is material to the original planner/executor shape, so this passing query cannot establish that the incident topology fails closed. Please retain the grouped-subquery shape while proving the failure is the HashBuild hard-budget rejection, with no result set/spill and a healthy CN afterward.

[P1] pkg/sql/colexec/hashbuild/build_test.go:234-246 does not exercise a shared broadcast execution: newTestCase fixes JoinMapRefCnt at 1, these four raw message readers start only after vm.Exec has already published the failure, and the SQL test separately forces max_dop = 1. This proves terminal-result replay, but not that a refcount>1 broadcast pipeline unblocks every real JoinMap consumer without partial probe output and then returns all accounting to zero. Please add an actual shared/parallel consumer topology and assert the same error, no-output, no-spill, and cleanup contract.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE — no blocking findings on exact head 72ac958. GitHub cannot record an APPROVED review because the authenticated account XuPeng-SH is the pull-request author. The previous grouped-subquery and real shared-consumer gaps are closed, and the partial-result oracle now rejects any non-nil Rows independently of cleanup errors. Verified the SQL witness retains Aggregate, broadcast/no-shuffle topology and DOP 2; the admitted control returns the exact payload, while the rejected case returns terminal MySQL OOM before a result set, does not spill, and leaves the CN healthy. The refcount=2 HashBuild/HashJoin path delivers the same error to both real consumers before probe input and returns memory/disk/FD accounting to zero. Focused packages pass, the real-consumer race regression passes 100 iterations, and the latest FK session-local visibility adjustment preserves the intended post-commit oracle.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Fixed the SCA failure in 5e9d730. sqlclosecheck requires the unexpected Rows handle to be closed by a defer, while rowserrcheck requires Rows.Err to be observed. The deferred cleanup now closes the unexpected handle and logs Close/Rows errors for diagnostics only. It never folds either value into the original QueryContext error, so a terminal OOM observed while draining an already exposed result set cannot satisfy the no-partial-result oracle. Validation after the edit: GOWORK=off golangci-lint run ./pkg/tests/issues reports 0 issues; the exact #25782 SQL regression passes; full pkg/tests/issues passes; git diff --check passes.

…ue-25782-broadcast-budget-validation

# Conflicts:
#	pkg/sql/colexec/hashbuild/build_test.go

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants