Skip to content

fix(ctl): reject short mo_ctl reader args with explicit invalid input (#31499) - #31528

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-31499
Oct 28, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-31499

Conversation

@aptend

@aptend aptend commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #31499

What this PR does / why we need it:

mo_ctl('cn', 'reader', <parameter>) split <parameter> on : and the branch that
forwards the command to another CN indexed args[2] without validating the shape, so an
empty, single-segment, or two-segment parameter panicked with index out of range on
multi-CN deployments and surfaced to SQL clients as internal error: panic ... with a
leaked Go stack, instead of a clean error.

The fix validates the parameter shape immediately after the split and before any CN is
enumerated, touched, or forwarded to. Malformed parameters now fail fast with
ERROR 20301 invalid input including the expected cmd:cfg:tid1,tid2[:blk_cnt] format
hint and trigger no cluster action; the documented commands (three-part
force_build_remote_ds and four-part force_shuffle with block count) behave as before
on both the local and forwarding paths.

Testing:

  • Source-level checks, all rc=0, rerun on the final PR tree (base main e9dc8c4, fix(sql): align approximate numeric text notation with MySQL #30316,
    plus this change; changed-file blobs reader.go 6428417fd58ad0f3f3da48e5e1c02310a89d439e
    and reader_test.go 39168fcce8bb3d5c2657ad7f75e0e09a0298704c, identical to the ones
    validated earlier):
    • mo-cgo-test -count=1 -run 'TestMoCtlReader' -v ./pkg/sql/plan/function/ctl/ - new
      TestMoCtlReaderRejectsShortParams (empty/single/two-segment parameters return an
      explicit invalid-input error, with zero transfer requests and no local application),
      TestMoCtlReaderAppliesValidParams (enable/disable and force_shuffle with block count
      applied and verified, case-insensitivity, graceful reports for shape-valid but
      unsupported commands), TestMoCtlReaderForwardsWellFormedParams (forwarded request
      cmd/cfg/extra shape for both documented forms) - pass.
    • Full package ./pkg/sql/plan/function/ctl/ tests - ok.
    • make static-check-selected STATIC_CHECK_PACKAGES=./pkg/sql/plan/function/ctl/...
      (molint + golangci-lint) - 0 issues.
  • Real SQL against a private single-process launch: all three malformed parameters return
    ERROR 20301 invalid input (no panic or stack in client output or server log), the same
    session continues with the legal commands afterwards, and
    enable/disable:force_build_remote_ds:1,2 apply on the local CN. The mo-service used
    for that run was built from main df8bfd6 with this same reader.go fix applied as an
    uncommitted change (binary sha256
    c1e04a54d92e33e41eaab3325f8189b44683b7e3b61a00c5e23cbd7f2313be8f); its reader.go content
    is byte-identical to the committed one.

Scope of the validation: the real-SQL run used a single CN only; cross-CN forwarding is
asserted by unit tests at the query-client boundary only (simulated forwarding), not by a
live multi-CN run.

…matrixorigin#31499)

mo_ctl('cn','reader',arg) split arg on ':' and indexed args[2] on the branch that forwards the command to another CN without validating the length, so an empty, single-segment, or two-segment parameter panicked with index out of range on multi-CN deployments and surfaced to SQL clients as an internal error with a leaked Go stack.

Validate the parameter shape right after the split and before any CN is enumerated, touched, or forwarded to: malformed parameters now fail fast with ERROR 20301 invalid input, including the expected cmd:cfg:tid1,tid2[:blk_cnt] format hint, and trigger no cluster action; valid commands (including the four-part force_shuffle form with block count) behave as before on both the local and forwarding paths.

Tests: focused TestMoCtlReader* suite, the full pkg/sql/plan/function/ctl package, and make static-check-selected all pass; real-SQL validation on a private single-process launch returned invalid input for all three malformed shapes on a reusable session and applied legal enable/disable commands (single CN; cross-CN forwarding is asserted by unit tests at the query-client boundary).
@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 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: b2ef169551d4fdce3bb9460a0617d28424b0f462

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: b2ef169551d4fdce3bb9460a0617d28424b0f462

Assessment: approve

The guard rejects short reader arguments before CN enumeration or side effects while preserving valid commands. Complete delta, consumers and issue #31499 reviewed; no actionable findings or unresolved discussion concerns.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Full ctl package tests passed, including malformed arguments, local settings and mocked two-CN forwarding.

  • SQL probe passed: six malformed inputs returned error 20301 with a format hint, preserved settings and allowed same-session recovery; four valid controls succeeded.

  • Baseline-handler overlay reproduced the original index-out-of-range panic.

  • Formatting, diff whitespace and ctl go vet passed. Isolation preflight and current-input native provenance passed.

  • Receipts, logs and overlay inputs reconciled in /home/xupeng/.local/state/mo-bot/jobs/9c12e70f8ab13e1476891636/attempt-1/validation-audit.json. Discussion ledger saved; source remains unchanged.

Limitations:

  • No fresh live multi-CN SQL run; remote dispatch was covered by mocked two-CN tests and source inspection.

  • The initial SQL probe used an incorrect JSON field name. Its failure is retained; the corrected probe passed.

@mergify mergify Bot added the queued label Oct 28, 2026
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

1 h 4 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Wed 28 Oct, 07:02 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 08:05 · 98ab2a4

Reason

Pull request #31528 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Merge conditions: 2 of 3 met

This pull request

Condition Required by
✅ #review-threads-unresolved = 0 GitHub branch protection
✅ github-review-approved GitHub branch protection

The batch, tested in place

Condition Required by
❌ any of: check-neutral = CI Required, check-skipped = CI Required, check-success = CI Required GitHub branch protection

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

@XuPeng-SH
XuPeng-SH merged commit 51d27a4 into matrixorigin:main Oct 28, 2026
21 of 22 checks passed
@mergify mergify Bot added dequeued and removed queued labels Oct 28, 2026

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

dequeued 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.

3 participants