matrixorigin / matrixorigin/matrixone
[Bug]: MERGEOBJECTS invalid targetObjSize enters pipeline panic recovery
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 311
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 768
Description
## Reproduction
Validated on latest `main`:
```
4dedea1ebe391c55715d324804ba4cd6ab1e4f08
```
Run the following SQL:
```sql
select mo_ctl('cn', 'MergeObjects', 't:probe_db.probe_table:small:not-a-size');
```
## Expected behavior
`not-a-size` is not a valid `targetObjSize`, so the statement should return a normal invalid-argument error for `targetObjSize`.
## Actual behavior
The statement enters the pipeline panic-recovery path and returns an internal error containing a Go stack trace:
```
internal error: panic runtime error: index out of range [3] with length 3
```
The stack points to `pkg/sql/plan/function/ctl/cmd_merge.go:164` in `parseArgsForPartitionTables`.
## Reproducibility and control
- Reproduced **3/3** times using three independent embedded-cluster SQL runs.
- After each failure, `SELECT 1` succeeds; the service stays available.
- Control input `t:probe_db.probe_table:small:1M` takes the normal path, returning only the expected missing-relation error for the intentionally absent table, with no panic.
## Root cause
For table form, the parser accepts at most three arguments after the merge type. When `args[2]` fails size parsing, the error branch reads `args[3]`, which is out of bounds. The object-form branch has the same pattern.
```go
size, err := units.RAMInBytes(args[2])
if err != nil {
return arguments{}, errors.Join(moerr.NewInvalidArgNoCtx("targetObjSize", args[3]), err)
}
```
Use `args[2]` in the error construction and add malformed-size coverage for both table and object forms.
Contributor guide
Assessment
This issue has not been assessed yet.