Repository navigation
fix(ctl): reject short mo_ctl reader args with explicit invalid input (#31499) - #31528
Conversation
…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 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? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
🚫 Left the queue1 h 4 min in the queue, with no time running CI. So far
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.
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. Merge conditions: 2 of 3 metThis pull request
The batch, tested in place
Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
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 thatforwards the command to another CN indexed
args[2]without validating the shape, so anempty, single-segment, or two-segment parameter panicked with
index out of rangeonmulti-CN deployments and surfaced to SQL clients as
internal error: panic ...with aleaked 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 inputincluding the expectedcmd:cfg:tid1,tid2[:blk_cnt]formathint and trigger no cluster action; the documented commands (three-part
force_build_remote_dsand four-partforce_shufflewith block count) behave as beforeon both the local and forwarding paths.
Testing:
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/- newTestMoCtlReaderRejectsShortParams(empty/single/two-segment parameters return anexplicit invalid-input error, with zero transfer requests and no local application),
TestMoCtlReaderAppliesValidParams(enable/disable and force_shuffle with block countapplied and verified, case-insensitivity, graceful reports for shape-valid but
unsupported commands),
TestMoCtlReaderForwardsWellFormedParams(forwarded requestcmd/cfg/extra shape for both documented forms) - pass.
./pkg/sql/plan/function/ctl/tests - ok.make static-check-selected STATIC_CHECK_PACKAGES=./pkg/sql/plan/function/ctl/...(molint + golangci-lint) - 0 issues.
ERROR 20301 invalid input(no panic or stack in client output or server log), the samesession continues with the legal commands afterwards, and
enable/disable:force_build_remote_ds:1,2apply on the local CN. The mo-service usedfor 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.