Skip to content

fix: recover legacy JSONLINE and retire locks on CN shutdown - #30832

Merged
XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
aptend:fix/jsonline-setval-scaledown-followups
Oct 23, 2026
Merged

XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
aptend:fix/jsonline-setval-scaledown-followups

Conversation

@aptend

@aptend aptend commented Oct 22, 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:

Related to #30635, #30650 and #29447.

What this PR does / why we need it:

After CN scale-down, the first DROP DATABASE could exhaust its 10s retry budget with Error 20702 because a departing CN remained the allocator's valid lock owner. Transaction cleanup could allocate that replacement owner; ordinary background SQL could also acquire ownership immediately before shutdown. Make remote Unlock recovery request an acknowledged, non-allocating GetBind lookup, and report completed LockService.Close through the existing exact-instance BeginDrain and epoch-confirmed terminal heartbeat before releasing its RPC client. The report follows local admission sealing, worker joins, physical-table destruction and transaction-holder cleanup. An invalid lookup retires only the exact stale cache generation and cannot publish a new physical table.

Lookup mode is an additive protobuf extension with an explicit response acknowledgement. Legacy responses still require a valid owner; absence without acknowledgement is never retirement proof. Close reporting checks the service incarnation, attempt and allocator epoch and shares one bounded RPC context. Unsupported peers, epoch replacement or transport failure retain timeout retirement and emit a diagnostic while preserving Close's existing local-error contract. The cleanup correction requires upgraded CN and allocator support; abrupt failure and unavailable control planes still use existing failure detection. No SQL retry budget or readiness condition is widened.

Old MatrixOne JSONLINE exports used bare Base64 strings for binary columns. Add the explicit read option json_binary='legacy_base64' to restore those archives while preserving default string imports. Validate infile, S3, Stage and read-only external-table consumers, persist the mode through configuration and SHOW CREATE, and reject malformed payloads and writable-table usage. Both record shapes and BINARY/VARBINARY/BLOB use the shared reader; decoded \N bytes remain non-NULL.

Preserve SETVAL's existing called-state behavior and expose all four previous-state/third-argument combinations in the SQL regression. For an ascending sequence away from its boundary, SETVAL(n,true) makes the next NEXTVAL return n only if the sequence was previously uncalled; an already-called sequence advances. The matching Chinese latest documentation is in matrixone-doc#733.

Validation on Linux/amd64, Go 1.27.1, with locally built CGo dependencies:

  • The same controlled three-CN SQL case fails against baseline production code at the first DROP with Error 20702. Final production code passes that case and the original scale-down regression under atomic coverage and race, retaining the original readiness and single-attempt DROP assertions. The historical failure is recorded in Linux coverage run 38882194805.
  • Seven focused ownership/protocol/cancellation tests plus the existing Unlock timeout and Close cleanup-error tests each pass 100 race repetitions. The controlled SQL race test measures 12.39s, followed by N=2 repetitions; the original measures 15.52s, followed by N=1. Full LockService normal and race suites pass; the dependent CN/SQL integration exercises the real shutdown path.
  • Focused JSONLINE reader/planner tests and full external, plan and parser-tree packages pass. Both SQL cases pass normal mo-tester comparison twice on the same real embedded SQL instance: JSONLINE 15/15 and SETVAL 32/32 per run, with teardown checked. A separate reconnect/SHOW CREATE replay probe verifies persisted mode and mixed legacy/wrapped payloads.
  • Changed-package gofmt, go vet and incremental golangci-lint pass for all seven packages; protobuf regeneration matches byte-for-byte. JSONLINE design revision 1 and lock cleanup/shutdown design revisions 1 and 2 were reviewed and committed before their implementations. Final self-review has no unresolved blockers.

Rebased onto upstream main 52af980b2089. Preserve the upstream JSONLINE text-fidelity regressions alongside the legacy binary recovery tests. On the rebased code, full external/plan/parser-tree packages, full LockService race, both scale-down SQL scenarios in atomic coverage and race, seven-package vet/lint, and both mo-tester cases twice on the same embedded SQL instance pass.

The previous-head UT job failed in TestIssue29399AccountRestoreRollsBackInvalidPrivileges during DROP ACCOUNT cleanup; its functional subtests passed. On this rebased head the unchanged test passes once under race and twice in one process with CI-equivalent GOMAXPROCS=2 -race -short, including the account/snapshot absence assertions. Existing test deadlines, cleanup checks and CI selection are retained. The complete CI is being rerun on this head; these focused results do not substitute for its terminal outcome. A new TKE deployment remains pending. No issue is closed automatically by this follow-up PR.

@aptend aptend changed the title fix: close JSONLINE, SETVAL and CN scale-down follow-ups fix: recover legacy JSONLINE and harden SETVAL/scale-down tests Oct 22, 2026
@mergify mergify Bot added kind/bug Something isn't working kind/documentation Improvements or additions to documentation kind/test-ci kind/api-change labels Oct 22, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Oct 22, 2026
@aptend
aptend force-pushed the fix/jsonline-setval-scaledown-followups branch from 4e38f64 to 1ab959f Compare October 22, 2026 10:59
@aptend aptend changed the title fix: recover legacy JSONLINE and harden SETVAL/scale-down tests fix: recover legacy JSONLINE and retire locks on CN shutdown Oct 22, 2026
@matrix-meow matrix-meow added size/L Denotes a PR that changes [500,999] lines and removed size/M Denotes a PR that changes [100,499] lines labels Oct 22, 2026
@XuPeng-SH

XuPeng-SH commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: c2365a4a84b1f1c5d5ca12ae82c14c3a8b6f51af

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

Assessment: approve

Reviewed the complete 28-file delta and affected callers. No actionable defects remain. The design keeps retirement in the existing allocator lifecycle and legacy decoding in the shared reader, preserves default behavior, and leaves SETVAL execution unchanged.

Model: gpt-6-astra / xhigh

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

Validation:

  • Verified the frozen head, unchanged source, complete patch correspondence, and generated protobuf descriptor compatibility.

  • Isolation preflight and native prerequisites built from the current revision passed.

  • Nine focused lockservice tests passed once and then 100 repetitions each under -race: 909 root-test passes. Exact commands, source fingerprints, exit receipts and retained logs were reconciled.

  • Reused frozen exact-head successful CI gates for build, UT, coverage, SCA and both BVT configurations.

  • Evidence mapping and detailed review retained in /home/xupeng/.local/state/mo-bot/jobs/bd8c8da8c1d074fa6e74dde9/attempt-1/validation-reconciled.json and review-notes.json.

Limitations:

  • CI raw logs and author-local artifacts were not supplied; their reported individual timings were not independently verified. No local TKE rollout or mixed-version cluster run was performed.

  • No throughput benchmark was run. Ordinary acquisition remains unchanged; Close adds two RPCs sharing a 10-second deadline, and opted-in binary decoding adds payload-proportional work. Unsupported or unavailable allocators retain timeout-based retirement.

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

mergify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-23 07:27 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in-place
  • 🚫 Left the queue — 2026-10-23 10:54 UTC · at 6bd96852121915fd2a03e0b1c85bbfb4f46b72cb

This pull request spent 3 hours 26 minutes 50 seconds in the queue, with no time running CI.

Reason

The merge conditions cannot be satisfied due to failing checks

  • CI Required

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, 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.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

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

  • Requeue this pull request

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/api-change kind/bug Something isn't working kind/documentation Improvements or additions to documentation kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants