Skip to content

test(sql): align ODKU CHECK cases with input validation - #33691

Merged
XuPeng-SH merged 1 commit into
matrixorigin:mainfrom
XuPeng-SH:fix/check-constraint-odku-bvt
Dec 2, 2026
Merged

XuPeng-SH merged 1 commit into
matrixorigin:mainfrom
XuPeng-SH:fix/check-constraint-odku-bvt

Conversation

@XuPeng-SH

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:

Related to #33536. Follow-up to #33687.

What this PR does / why we need it:

The CHECK BVT still expected an invalid incoming row to update an existing row when the duplicate-key assignment had a valid value. #33687 validates the incoming row before duplicate-key arbitration.

Keep that input in the script and assert the CHECK violation and the unchanged stored value. Use a valid incoming row with an invalid assignment to cover CHECK on the UPDATE image independently. A valid input and assignment still update the row to 30.

Ran both versions of check_constraint.test against a local MatrixOne cluster at d96cdf0c26 with the failing job's mo-tester revision 309a0ca650. The old script reproduced all 3 failures. The updated script passed 71/71 statements. The full Compose BVT suite was not run locally.

@XuPeng-SH
XuPeng-SH merged commit faafdf4 into matrixorigin:main Dec 2, 2026
@XuPeng-SH
XuPeng-SH deleted the fix/check-constraint-odku-bvt branch December 2, 2026 17:40
@mergify mergify Bot added the kind/test-ci label Dec 2, 2026
@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 added a commit that referenced this pull request Dec 3, 2026
## What type of PR is this?

- [x] BUG

## Which issue(s) this PR fixes:

Related to #33556.

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

The proxy rebalancer could leave an existing session on a CN that the
current route no longer selects. With one eligible target, the load
threshold can prevent migration from the obsolete source. This is
consistent with the placement error in #33556, although the incident's
exact connection path could not be recovered.

Each rebalance pass fixes its registration boundary before reading CN
discovery. It applies the shared routing policy for removed, draining,
and relabeled sources, including the existing sys root/dump fallback and
a live plugin destination for sessions that originally used Bypass.
Backend registrations carry their own route origin during migration and
rollback. Built-in pool balancing excludes retained plugin sessions
outside that pool. A pass attempts at most one synchronous discovery
refresh, reuses compiled label patterns, and defers busy tunnels. Plugin
probes use the configured RPC timeout.

### Validation

- The previous implementation reproduced the stale-view and sys fallback
failures on the same main base. Both regressions pass with the fix.
- The full race suites for proxy, cluster service, and route passed on
`16b9b15643`. The Proxy suite included the embedded-cluster session
migration test and ran with the local HAKeeper listener isolated. Seven
focused race tests passed 100 repetitions each, including the two-CN
migration followed by a SQL request. The two-CN balance test passed 63
repetitions. Vet and incremental SCA passed.
- After rebasing onto `914470d753`, the Proxy race regressions passed
again. The intervening base commit updates IVFFlat and the Proxy,
cluster-service, route, and native build source files are byte-identical
to the tested version.
- In a local steady-state benchmark with 64 tenants, 128 CNs and 4,096
registrations, median pass time fell from 7.59 ms to 5.08 ms, and bytes
allocated per pass fell from 2.92 MB to 0.70 MB.

### Review follow-up (2026-12-02)

- A queued rebalance request now retains the selected backend
registration and checks it again before transfer, so a completed
migration invalidates stale work. It also checks the current tenant
route before evacuating a source or balancing away from the only
remaining tenant CN.
- A busy tunnel on a draining CN retains scaling transfer intent even if
that CN disappears from discovery before the next scan. Tunnel close
clears the intent.
- Added regressions for route relabeling, stale backend registration,
shrinking balance pools, and busy scaling delivery after CN removal.
Focused proxy tests and the same focused race tests passed; `go vet
./pkg/proxy` passed. Merged upstream `main` at `f9d52a3a39`.

### Verify the plugin's current selection against the registered
endpoint

An existing TCP connection may record `127.0.0.1:port` as its peer while
the CN advertises `localhost:port`. When a plugin switches from Bypass
to Select, the proxy now checks a serving recommendation against the
registered CN ID and advertised address before retaining the session. A
changed advertised address still permits evacuation.
[Review](#33568 (review))

- Rebased onto main `edd86400a89a`. The hostname regression reaches the
tunnel's real destination selection with a TCP socket and a mock CN
registration. On the reviewed code it attempted a replacement dial. On
the corrected code it retains the source when the plugin still selects
it. Controls exercise changed recommendations, a changed advertised
endpoint, a draining source and load balancing.
- Full race runs passed for `pkg/proxy` (37.042s), `pkg/clusterservice`
(3.465s) and `pkg/vm/engine/disttae/route` (3.380s). They include
automatic two-CN migration followed by a MySQL request and real session
migration with privilege checks. The hostname regression passed 100/100
repeats under race.
- The incremental SCA selector covered 18 packages for this review fix.
Molint and golangci-lint passed. [Previous full PR
CI](https://github.com/matrixorigin/matrixone/actions/runs/47020822961)

### Rebased validation for `89068bb76c96` on main `faafdf4fef03`

The tested checkout `7be7ae2c341b` matches the published Git tree
`9c13314c471196025052449bca3514f8804bad10`. The run used Go 1.27.1 on
Darwin ARM64 and the checked native library profile. The package-wide
race run completed with exit 0.

```text
ok  github.com/matrixorigin/matrixone/pkg/proxy  24.612s
ok  github.com/matrixorigin/matrixone/pkg/clusterservice  1.674s
ok  github.com/matrixorigin/matrixone/pkg/vm/engine/disttae/route  1.308s
```

The suite includes `TestRebalanceFallbackToNewlyLabeledCN`, which checks
one automatic transfer and a successful MySQL command afterward, and
`TestRenameUserProxyMigrationPrincipal`, which opens a real client
session through Proxy on a two-CN cluster and verifies identity and
privileges after transfer. The focused runs separately stress the
deferred evacuation and observed drain paths.

| Exact test under race | Passed |
| --- | ---: |
| `TestDeferredEvacuationKeepsRecoveredSource` | 100/100 |
| `TestScalingRetainsUnqueuedDrain` | 100/100 |
| `TestRebalanceRejectsSupersededRegistration` | 100/100 |
| `TestTransferRouteKeepsPreferredTier` | 100/100 |
| `TestRebalanceFallbackToNewlyLabeledCN` | 100/100 |
| `TestRenameUserProxyMigrationPrincipal` | 3/3 |

Incremental molint and golangci-lint passed on those three packages. The
local package-race JSON receipt has SHA-256
`1ce1ecdde9172ce921b0c038085dc5b2ba492c998408a0e7393fe00747b710d9`. The
base contains #33691, which updates the ODKU CHECK expectations that
failed the previous Compose BVT job. The original connection path in
#33556 remains unknown.

---------

Co-authored-by: XuPeng-SH <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant