Skip to content

fix(frontend): align PITR publication query projection with its row parser (#30607) - #30643

Merged
mergify[bot] merged 4 commits into
matrixorigin:mainfrom
daviszhen:fix-30607-pitr-pub-layout
Oct 20, 2026
Merged

mergify[bot] merged 4 commits into
matrixorigin:mainfrom
daviszhen:fix-30607-pitr-pub-layout

Conversation

@daviszhen

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Rendering
  • BUG
  • Performance
  • Test
  • Others

Which issue(s) this PR fixes:

issue #30607

What this PR does / why we need it:

RESTORE DATABASE ... FROM PITR fails for any database referenced by a publication:

ERROR 1105 (HY000): strconv.ParseInt: parsing "pubpxb": invalid syntax

and the database is left unrestored.

Root cause

pkg/frontend declares two mo_pubs column layouts (post/pre account_name). The restore path in createPubByPitr queries with getPubInfoWithPitrFormat, which used a third, shortened projection starting at pub_name — while the rows were parsed by extractPubInfosFromExecResult, which reads account_id (int64) at column 0. The publication name string landed in that slot and strconv.ParseInt rejected it. The sibling snapshot path (getAllPubInfosBySnapshotName) already queried the correct 12-column layout.

Fix

Make getPubInfoWithPitrFormat project the same 12-column layout as the extractor: (account_id, account_name, pub_name, database_name, database_id, table_list, account_list, created_time, update_time, owner, creator, comment). One-line production change; all other readers audited and already consistent.

Tests

  • Test_getPubInfoWithPitrLayout: pins the PITR query's projection equal to getPubInfoSql's and parses a realistic row into the right PubInfo fields; fails on main (proven).
  • Test_createPubByPitr row fixtures migrated to the real 12-column shape; newMrsForSqlForGetPubs builder updated to match.
  • go test ./pkg/frontend/ all pass.

Live end-to-end (exact issue scenario, isolated 1 LOG/1 TN/1 CN)

Baseline binary: bug reproduces verbatim — ERROR 1105: strconv.ParseInt: parsing "pubpxb": invalid syntax.
Fixed binary (fresh store):

insert into pubB.t values (10),(11);            -- after marker T
restore database pubB from pitr p1 '<T>';       -- OK (was ERROR 1105)
select * from pubB.t;                           -- 1,2 (10,11 rolled back)
show publications;                              -- pubpxb re-created for db pubb

…arser (matrixorigin#30607)

RESTORE DATABASE ... FROM PITR reads the restored database's publications
through getPubInfoWithPitrFormat, which projected mo_pubs as
(pub_name, database_name, ...). createPubByPitr then parsed the rows with
extractPubInfosFromExecResult, which expects the 12-column layout starting
with (account_id, account_name). The pub name landed in the first column
and restore aborted with
"strconv.ParseInt: parsing \"<pub_name>\": invalid syntax", so a
published database could never be restored via PITR (while the same
restore succeeded for unpublished databases).

Make the PITR query project the same 12-column layout as the extractor,
matching getAllPubInfosBySnapshotName's already-correct snapshot query.
Regression tests pin the projection against getPubInfoSql and verify a
realistic row parses into the right PubInfo fields; both fail on main.
@daviszhen
daviszhen requested a review from XuPeng-SH as a code owner October 20, 2026 04:43
@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 →

@daviszhen

Copy link
Copy Markdown
Contributor Author

Local verification at head 40a6ef5 (isolated 1 LogService / 1 TN / 1 CN, fresh stores, exact reporter recipe with pitr range 3 'h', acc1, pubB.t, publication pubpxB):

Baseline (upstream/main @ 983ab88)

restore database pubB from pitr p1 '2026-10-20 12:40:30';
-- ERROR 1105 (HY000): strconv.ParseInt: parsing "pubpxb": invalid syntax

This fix

restore database pubB from pitr p1 '2026-10-20 12:42:30';   -- OK
select count(*) from pubB.t;                                 -- 2 (rows 10,11 inserted after T rolled back)
select * from pubB.t order by id;                            -- 1, 2
show publications;                                           -- pubpxb | pubb | * | acc1  (publication re-created)

Unit: Test_getPubInfoWithPitrLayout fails on main (projection mismatch vs extractor; verified) and passes here; other extractPubInfosFromExecResult call sites audited — all use the 12-column getPubInfoSql/getAllPubInfoSql. go test ./pkg/frontend/ all pass at 40a6ef5.

@XuPeng-SH

XuPeng-SH commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · superseded

Commit: 6901c2077ed1d14c74a19ff75074f02737851277

"interrupted"

@XuPeng-SH

XuPeng-SH commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 6901c2077ed1d14c74a19ff75074f02737851277

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: 6901c2077ed1d14c74a19ff75074f02737851277

Assessment: request_changes

The projection correction appropriately reuses the existing row extractor. However, it enables successful restores that silently swap publication owner and creator IDs. Reviewed all three changed files and their restore consumers; one actionable correctness issue remains.

Model: gpt-6-astra / xhigh

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

  • P2 pkg/frontend/pitr.go:78: Restore a published database whose publication creator user ID differs from its owner role ID, such as a publication created by dump.
    Impact: RESTORE succeeds but persists incorrect publication ownership and creator metadata. Complete the replay fix by supplying Creator as the user ID and Owner as the role ID, and test successful nonempty publication replay with distinct IDs.
    Evidence: The current-head native MySQL test restored the expected rows but changed (owner=0, creator=1) to (owner=1, creator=0). createPubByPitr at line 2655 passes Owner, Creator to AttachAccount, whose arguments are userId, roleId; the catalog writer then stores roleId, userId. This inversion predates the patch, but the corrected projection makes it reachable: the base-projection control aborts earlier with the original ParseInt error. See public-pitr.log and base-control.log.

Validation:

  • Artifacts are retained under /home/xupeng/.local/state/mo-bot/jobs/9b8874ac71f91b3ebb0c7bb0/attempt-1. review-evidence-audit.json reconciles commands, input hashes, native provenance, logs and receipts; source remains unchanged.

  • Isolation preflight and repository-owned native build passed. Tests used the assigned caches and supplied test-exec.

  • Complete frontend suite passed, including the new layout regression and legacy extractor tests: frontend-normal.log; receipt 1792475414204663283-3.json, exit 0.

  • Current-head public RESTORE probe failed the ownership-preservation assertion: public-pitr.log; receipt 1792475490635437218-3.json, exit 1.

  • The base pitr.go overlay reproduced the original ParseInt error as expected: base-control.log; receipt 1792475545620675462-3.json, exit 0.

  • The change adds two required projected fields without changing query count, filters or ordinary SELECT/DML/DDL paths. Design, test-quality and compatibility analysis is retained in review-scope-notes.json.

Limitations:

  • The author’s live report references an earlier head without retained execution artifacts here; current-head conclusions rely on local validation.

  • No cross-version, multi-CN or performance benchmark was run. Native validation used one isolated LOG/TN/CN cluster per test binary.

  • Initial setup receipts lack Git fingerprints because they ran outside the checkout; native build and all test receipts identify the exact clean head.

@XuPeng-SH

XuPeng-SH commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · superseded

Commit: e42ce6d836799f8c3469acd83277b688cba00885

Review belongs to an older commit; it is not a review of the current head.

@XuPeng-SH

XuPeng-SH commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: e42ce6d836799f8c3469acd83277b688cba00885

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

Assessment: approve

Reviewed all three changed files and their restore consumers. The fix correctly aligns the projection with the existing extractor and preserves publication owner/creator identities. It retains existing transaction and cleanup ownership, adds no queries or normal SQL-path work, and closes the prior finding.

Model: gpt-6-astra / xhigh

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

Validation:

  • Isolation preflight passed; recovered native artifacts matched current inputs and passed repository provenance verification.

  • Current-head frontend suite passed: 2,483 top-level passes and one preexisting skip. frontend-normal.log; receipt 1792485617462659868-3.json, exit 0.

  • Current-head public MySQL RESTORE probe passed: restored rows [1,2], correct publication database reference and metadata, and unchanged owner=0/creator=1. public-pitr.log; receipt 1792485656707634448-3.json, exit 0.

  • Retained negative-control logs, commands and hashes were independently reconciled. Source, overlays and current execution receipts are audited in /home/xupeng/.local/state/mo-bot/jobs/5a99c97c3a66d4e69af274cb/attempt-1/validation-audit.json; all 11,609 tracked files remained unchanged.

Limitations:

  • Public validation used one isolated LOG/TN/CN cluster; no cross-version or multi-CN restore run or performance benchmark was performed.

  • The standalone linked issue body was not supplied; its scenario was assessed from the frozen PR description and comments.

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

mergify Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-20 08:43 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-10-20 13:32 UTC · at 5d79a583e858cf8d3924f4b7d4ce3b760ca4364c · squash

This pull request spent 4 hours 49 minutes 45 seconds in the queue, including 1 hour 9 minutes 11 seconds running CI.

Required conditions to merge

This branch was previously deployed

1 inactive deployment
ci — e0bea11e Deployed Oct 20, 2026 by mergify[bot]
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.

3 participants