Skip to content

[4.2] fix(disttae): handle empty TN response in table stats - #27158

Merged
XuPeng-SH merged 2 commits into
matrixorigin:4.2-devfrom
LeftHandCold:backport/4.2-26779-empty-tn-response
Aug 14, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:4.2-devfrom
LeftHandCold:backport/4.2-26779-empty-tn-response

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #26779

What this PR does / why we need it:

Backports #26782 (c72224bea6) to 4.2-dev.

Adds a shared ctl.GetFirstTNResponse boundary for callers that require a TN response. When no TN is available, table statistics, SHOW ACCOUNTS storage usage, and mo_ctl(..., INSPECT, ...) now return ErrNoAvailableBackend instead of indexing an empty result and panicking the CN. Commands where an empty target set is valid continue to consume Result.Data directly.

The original regression tests are included unchanged.

Testing

  • go test -mod=readonly -count=1 -timeout 180s ./pkg/sql/plan/function/ctl ./pkg/frontend ./pkg/vm/engine/disttae

…6782)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#26779

## What this PR does / why we need it:

Adds a shared `ctl.GetFirstTNResponse` boundary for callers that require
a TN response. When no TN is available, table statistics, `SHOW
ACCOUNTS` storage usage, and `mo_ctl(..., INSPECT, ...)` now return
`ErrNoAvailableBackend` instead of indexing an empty result and
panicking the CN. Commands where an empty target set is valid continue
to consume `Result.Data` directly.

Adds regression coverage for the shared boundary, table statistics, and
`SHOW ACCOUNTS`.

---------

Co-authored-by: XuPeng-SH <[email protected]>
@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 →

@XuPeng-SH XuPeng-SH 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.

Deep review of head fbee825.

This is an exact semantic backport of the merged main fix c72224b: both diffs have the same stable patch-id. The empty-target invariant is closed for every strict first-response consumer on 4.2-dev: table stats, SHOW ACCOUNTS storage usage, and mo_ctl INSPECT now return ErrNoAvailableBackend through GetFirstTNResponse. The remaining snapshot-read consumer already handles an empty target set explicitly as a valid unsuccessful response.

I also traced TN disappearance after enumeration. Send, stream creation, and receive failures return errors; successful sends preserve response cardinality, including cached-write response trimming, so the same panic is not left behind in a short-response path.

No correctness, compatibility, resource-lifecycle, hang, or performance blocker found. The normal-path cost is one type assertion and one length check, with no extra RPC, retry, allocation growth, lock, or scan.

Validation:

  • focused empty-TN regressions for ctl, frontend, and disttae passed under -race
  • full tests for all three changed packages passed
  • go list, go build, and go vet for all three changed packages passed
  • git diff --check passed

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

kind/bug Something isn't working 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