Skip to content

[4.2-dev] fix(compile): preserve exact catalog DDL locks during restore - #33458

Merged
XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
XuPeng-SH:fix/4.2-restore-exact-catalog-locks
Nov 30, 2026
Merged

XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
XuPeng-SH:fix/4.2-restore-exact-catalog-locks

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes

Fixes #33325.

What this PR does / why we need it

RESTORE CLUSTER could fail with MySQL error 20105 while dropping an existing table. The restore transaction already enabled exact catalog prelocks, but DDL's separate catalog row helper still allowed lock escalation. Once the lock-key ledger reached its segment capacity, the exclusive mo_tables request tried to absorb a row shared with another transaction. The failing job reported this on the cluster-restore half of the account-lock test. Ubuntu x86 UT log

Route database and table catalog DDL locks through one helper. It reads the existing catalog-maintenance policy and keeps those keys exact across lock-key segments. Ordinary DML retains its range escalation.

Testing

  • The same authenticated MySQL test returned 20105 twice on the 4.2-dev baseline with a shared catalog holder. Direct account removal succeeded before each restore failed in its internal DROP TABLE.
  • The fix completes cluster restore while another transaction still holds the shared catalog key. The test verifies both account removal and restoration of the table's row.
  • Race checks cover restore, catalog DDL retries, exact-row lock-key segments, normal DML metadata ranges and cross-CN publication locks.
  • After rebasing to 4.2-dev@df65fa5b21, all five selected embedded MySQL tests passed under the race detector. Focused compiler and lock-operation race checks passed. Scoped go vet and incremental golangci-lint passed, and the pinned molint emitted the same six diagnostics as the base.

Apply the existing maintenance transaction policy to database and table catalog DDL locks. Pin a concurrent shared key in the MySQL restore regression.
@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 →

@mergify

mergify Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@XuPeng-SH

XuPeng-SH commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: e8bc190dccd703e8ecbb80d20548641b1b005a6f

linked issue or PR description changed before publication

@XuPeng-SH

XuPeng-SH commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: e8bc190dccd703e8ecbb80d20548641b1b005a6f

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: e8bc190dccd703e8ecbb80d20548641b1b005a6f

Assessment: approve

The change applies the existing catalog-maintenance exact-row policy to DDL locks, addressing the shared-holder restore failure while retaining ordinary DML escalation. The newly supplied QA report describes failures on the target base; the matching candidate-head test passed.

Model: gpt-6.1-terra / max

Session: 01a22868-9ecc-7250-9120-16606b40e9e2 · slot 0 · generation 44

Validation:

  • Reused same-head race results for the shared-holder DROP and restore test, ordinary DML control, and cross-CN publication restore test. Receipt: reused-validation/checks/1795979771426102454-3.json.

  • The same shared-holder test failed with error 20105 when target-base ddl.go was overlaid. Receipt: reused-validation/checks/1795979872125756964-3.json.

  • Focused compiler, lock-operation, and local and remote exact-lock tests passed under the race detector. Receipts: reused-validation/checks/1795979914006216552-3.json and reused-validation/checks/1795979956268805914-3.json.

  • A diagnostic two-CN shared-holder restore passed with MaxLockRowCount=1 and the default fixed-slice size. Receipt: reused-validation/checks/1795980461769306571-3.json.

  • The reused evidence was checked against the current source, patch, test selection, native inputs, preflight, and terminal receipts. Results are retained in reuse-audit.log and reused-validation/.

Limitations:

  • A separate diagnostic two-CN restore with MaxFixedSliceSize=4 failed with error 20707 during mo_indexes cleanup. The candidate also failed without the external holder; the target-base DDL control failed earlier at mo_tables. This is distinct from the reviewed 20105 path and was not established as a regression from this change.

  • The QA report's release-holder retry and larger-budget controls were performed on the target base. Detailed author validation logs and a complete CI result were not supplied.

@XuPeng-SH
XuPeng-SH merged commit 70bb7b3 into matrixorigin:4.2-dev Nov 30, 2026
35 checks passed
@XuPeng-SH
XuPeng-SH deleted the fix/4.2-restore-exact-catalog-locks branch November 30, 2026 00:07
XuPeng-SH pushed a commit that referenced this pull request Nov 30, 2026
…n ID (#33424)

## What type of PR is this?

- [x] BUG

## Which issue(s) this PR fixes:

- #33376

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

Nine paired field timeouts showed different connection IDs at the Proxy
and CN. The Proxy previously accepted the CN greeting and forwarded the
client login, so the failure surfaced later as a backend authentication
timeout. The field logs do not establish why the CN missed the
connection preface.

The Proxy now checks the greeting against the ID it sent on that
physical connection. A mismatch closes that candidate before forwarding
login and lets the router try another eligible CN. The existing
greeting-stage diagnostic includes both IDs and classifies the failure
as non-timeout. Its structured `connection_id` is the request ID sent in
ExtraInfo, including when the greeting is rejected. A candidate rejected
during the greeting has no connection-manager registration to remove.
Its cleanup preserves the live tunnel in the routing, drain, and
connection-ID indexes, including when a Unix socket address alias
selects the same CN. Closing a superseded backend also preserves the
replacement's connection-ID entry. A separate pre-existing case remains
when a candidate registers after a successful handshake and destination
migration then fails.

The comparison runs once when opening a backend connection, before SQL
execution.

### Validation

- A real MySQL driver logged in through Proxy and directly to a
proxy-enabled CN. Both connections executed `SELECT 1` and `SELECT
CONNECTION_ID()`.
- The full `pkg/proxy` suite passed normally and under `-race`. Isolated
backend tests cover zero and nonzero IDs, closure before login, retry on
a healthy alternative, and registration ownership during migration.
- Go vet, molint, and incremental golangci-lint passed for `pkg/proxy`.

After rebasing onto official `4.2-dev` (`57cd85573c`), both original
patches matched in `git range-diff`. On `1e91864079` (Go 1.26.4, Darwin
arm64), `mo-cgo-test -v -count=1 -timeout=180s ./pkg/proxy`,
`mo-cgo-test -race -v -count=1 -timeout=240s ./pkg/proxy`, and `go vet
-mod=readonly ./pkg/proxy` passed. The MySQL driver smoke test and lint
results above are from the original validation.

The review fix at `cfbd93c894` was tested on official `4.2-dev`
(`2bdc8daf52`) with Go 1.26.4 on Darwin arm64. `mo-cgo-test -count=1
-timeout=180s ./pkg/proxy` and `mo-cgo-test -race -count=1 -timeout=240s
./pkg/proxy` passed. Focused race runs passed 54 iterations for backend
greeting ownership and 100 for cached backend rebinding. `go vet
-mod=readonly ./pkg/proxy`, molint, and incremental golangci-lint
passed. The fake CN verifies Proxy rejection and index ownership. The
real-CN timing and MySQL driver observations above come from the earlier
validation.

The CI refresh at `19b151353a` rebases the three unchanged Proxy patches
onto official `4.2-dev` (`70bb7b3515`), which includes the catalog DDL
and focused restore test updates from #33458. On Darwin arm64 with Go
1.26.4, `mo-cgo-test -short -race -tags matrixone_test -p 1 -count=3`
passed both `TestDropAccountWithMinimumRowLockCount` and
`TestAlterPublicationExplicitTargetLockScope`. The complete `pkg/proxy`
suite passed in the same mode with `-count=1`. The earlier [Linux x86
run](https://github.com/matrixorigin/matrixone/actions/runs/46284766742)
passed Proxy but failed in the isolated catalog package, with a restore
race and an unlock fatal during CN startup. The [Linux x86 UT and CI
Required
checks](https://github.com/matrixorigin/matrixone/actions/runs/46342788817/attempts/2)
passed on `19b151353a`.

The [handshake diagnostic
follow-up](#33424 (review))
at `3e4969685b90` was validated on Darwin arm64 with Go 1.26.4. Before
the fix, two assertions reproduced a structured ID mismatch for request
IDs 0 and 42. After the fix, `TestRouter_BackendHandshakeConnectionID`
passed 20 repetitions under `-race -tags matrixone_test`. The full
`pkg/proxy` suite passed normally and under `-race -tags
matrixone_test`. Go vet, molint, and incremental golangci-lint passed.
Linux CI for this follow-up will run after push.

Main PR: #33423

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

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

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.

2 participants