Repository navigation
fix(disttae): handle empty TN response in table stats - #26782
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of head 1f9d848. No code was changed.
P1 — The empty-TN success contract still leaves sibling process-panic paths
The new length check protects only getChangedTableList, but the source of the invalid state is still in ctl.GetTNHandlerFunc: when cluster.GetTNService discovers no target, it returns a nil error with Data set to an empty []any. Other callers still treat nil error as proof that a response exists. A concrete public path is frontend.requestStorageUsage, which calls the same helper and then unconditionally returns result.Data.([]any)[0]. With an empty or expired storage-usage cache, SHOW ACCOUNTS during the same TN-restart window still reaches an index-out-of-range panic. ctl.MoCtl has the same unchecked [0] access for INSPECT.
This means the PR fixes one table-stats symptom while the shared no-backend contract can still crash a CN from sibling consumers. The no-target condition should be owned at GetTNHandlerFunc, with any intentionally empty-result command made explicit, or every consumer must be audited and guarded. The regression should cover the common handler boundary and at least the SHOW ACCOUNTS fallback, not only the local table-stats indexing site.
Validation on this head: the new focused regression passed, the full pkg/vm/engine/disttae test package passed, go build and go vet passed, and git diff --check is clean.
|
Addressed the empty-response review in dd124d5:
Focused regressions, full owning-package tests, build, and vet pass for |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of head dd124d5.
The previous P1 is resolved systematically: strict single-response consumers now share GetFirstTNResponse and return ErrNoAvailableBackend for an empty TN target set. The affected table-stats, SHOW ACCOUNTS/storage-usage, and mo_ctl INSPECT paths are all guarded; the remaining snapshot-read consumer explicitly treats an empty set as a valid unsuccessful response.
I also traced TN disappearance after target enumeration through txnOperator.Debug and rpc.sender.Send. Send/build-stream/receive failures return an error, while successful sends preserve response cardinality, including cached-write response trimming, so this change does not leave the same failure mode behind a short-response panic.
No correctness, compatibility, resource-lifecycle, hang, or performance blocker found. The hot-path cost is only a type assertion and length check, with no extra RPC, retry, allocation growth, lock, or scan.
Validation:
- focused empty-TN regressions for ctl, frontend, and disttae passed
- full tests for all three changed packages passed
- go vet for all three changed packages passed
- git diff --check passed
## 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 #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` Co-authored-by: aptend <[email protected]> Co-authored-by: XuPeng-SH <[email protected]>
…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]>
…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]>
…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]>
What type of PR is this?
Which issue(s) this PR fixes:
issue #26779
What this PR does / why we need it:
Adds a shared
ctl.GetFirstTNResponseboundary for callers that require a TN response. When no TN is available, table statistics,SHOW ACCOUNTSstorage usage, andmo_ctl(..., INSPECT, ...)now returnErrNoAvailableBackendinstead of indexing an empty result and panicking the CN. Commands where an empty target set is valid continue to consumeResult.Datadirectly.Adds regression coverage for the shared boundary, table statistics, and
SHOW ACCOUNTS.