Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
b24d1b3 (2026-10-16)
Other Environment Information
- Hardware: macOS arm64 (Apple Silicon)
- Topology: single-node standalone
- OS: macOS
Actual Behavior
RESTORE DATABASE ... FROM PITR fails completely when the target database is referenced by a publication. The restore aborts with a raw strconv error leaking an internal column-layout mismatch:
ERROR 1105 (HY000) at line 1: strconv.ParseInt: parsing "pubpxb": invalid syntax
(the string being parsed is the publication's own name). The database is left unrestored — data written after the target timestamp is NOT rolled back, so recovery silently fails with no side effects applied.
Isolation matrix (all three cases same instance, same PITR p1):
| Case | Publication state | Restore result |
|---|---|---|
| A | no publication exists | success (data rolled back to target timestamp) |
| B | publication targets the restored database | fails with strconv.ParseInt: parsing "<pub_name>": invalid syntax, no restore |
| C | publication exists but references a different database | success |
Steps to Reproduce
create pitr if not exists p1 for account range 3 'h';
create account acc1 admin_name 'admin' identified by 'admin123';
create database pubB;
create table pubB.t (id int primary key);
insert into pubB.t values (1),(2);
create publication pubpxB database pubB account acc1; -- key ingredient
-- wait > pitr granularity, e.g. 60s, then record T slightly in the past:
-- T = date_sub(now(), interval 5 second)
insert into pubB.t values (10),(11); -- data that should be rolled back
restore database pubB from pitr p1 '<T>';
-- ERROR 1105: strconv.ParseInt: parsing "pubpxb": invalid syntax
-- pubB.t still contains the rows inserted after T (restore did not happen)Reproduced 3/3 on fresh standalone instances.
Root cause direction
pkg/frontend/publication_subscription.go has two different column layouts for reading mo_catalog.mo_pubs:
getPubInfoSqlOld = "select account_id, pub_name, database_name, database_id, ..."
getPubInfoSql = "select account_id, account_name, pub_name, database_name, database_id, ..."The restore path selects mo_pubs rows while rebuilding the target database and parses a column that it expects to be numeric (account_id / database_id), but the column actually read is the publication name string — i.e. a column-order mismatch between the old/new getPubInfoSql layouts (the row scanner position does not match the selected layout). The error string parsing "pubpxb" (the pub name) confirms a text field is being fed to strconv.ParseInt.
Expected Behavior
Restoring a database that is being published must either (a) succeed, treating mo_pubs rows correctly regardless of layout, or (b) return a clean, actionable error. Today the restore neither works nor explains itself; a published database is simply unrecoverable via PITR, while the documented purpose of PITR is to recover user databases — and creating a publication is a perfectly legal state for a user database.
Additional information
- Related known issue [Bug]: CDC must recover or fail explicitly after source-generation changes #30512 (PITR account restore kills CDC) shows the PITR-restore × replication-protocol intersection is fragile; this bug is the same intersection from the publication side.
- Existing unit test
snapshot_pubsub_restore_test.gocovers the subscriber-side subscription restore, but not the publisher-side database restore with live publications — this scenario is untested upstream.
Activity
Ariznawlll commentedon Oct 19, 2026
Precise root cause located
The failing component is
createPubByPitr(pkg/frontend/pitr.go:2607, called at pitr.go:1621): after a PITR database restore it re-creates publications by readingmo_catalog.mo_pubs {MO_TS = ...}viagetPubInfoWithPitrFormat:The result is parsed by
extractPubInfosFromExecResult, which expects the currentmo_pubscolumn layout (which since theaccount_nameaddition is:account_id, account_name, pub_name, database_name, database_id, ...). The{MO_TS}query above selects a historical projection whose column order no longer matches the extractor — so apub_namestring ("pubpxb") ends up in thedatabase_id/account_idposition andstrconv.ParseIntfails, aborting the whole restore.So the previously reported layout mismatch is between
getPubInfoWithPitrFormat(pitre.go:74) andextractPubInfosFromExecResult, not just betweengetPubInfoSqlOldandgetPubInfoSql. The fix should either add the missingaccount_namecolumn togetPubInfoWithPitrFormat/align the extractor, or make the extractor read columns by name.fix(frontend): align PITR publication query projection with its row p…
Ariznawlll commentedon Oct 20, 2026
测试版本
main774d0eda08c622e8717bed8caa8cd8c2ae3ffc2a(测试前核对官方origin/main;修复 PR fix(frontend): align PITR publication query projection with its row parser (#30607) #30643 的 merge commit5d79a583e858cf8d3924f4b7d4ce3b760ca4364c是其祖先)mo-service -launch etc/launch/launch.toml,1 CN / 1 TN / 1 LogService,MySQL 6001;SELECT git_version()返回774d0eda08。未使用共享 TKE 或外部故障注入。原问题验证
按原报告的 PITR 时间粒度等待超过 60 秒后,在时间点前插入
(1,'initial'),(2,NULL),时间点后插入(10,'later'),(11,NULL),对仍有 live publication 的数据库执行RESTORE DATABASE ... FROM PITR。修复后该路径 3/3 成功;每轮恢复前 4 行、SUM(id)=24,恢复后精确为(1,'initial'),(2,NULL)两行、SUM(id)=3,后插入行全部消失,publication 元数据仍为 1 条。原先的strconv.ParseInt: parsing "pubpxb"错误未再出现。Happy Path 覆盖
NULL均恢复到时间点,publication 保留。Unhappy Path 覆盖
(20,'sentinel')后用非法时间字符串恢复,3/3 返回错误 1105;原有两行、sentinel 及 publication 均保持不变。mo_pubs与数据库残留均为 0。白盒验证
在同一完整 SHA 上运行
Test_getPubInfoWithPitrLayout|Test_createPubByPitr -count=3,通过。修复 PR #30643 的 UT Coverage、multi-CN PESSIMISTIC BVT、PROXY BVT、CI Required 检查成功。白盒结果只作辅助,关闭依据包括上述真实 SQL/PITR 路径。回归测试
已将独立 oracle 的时间点前后数据、发布元数据、原始 A/B/C 路径和失败原子性加入 MOTR #247,commit
2f9726f3,文件:Python 场景、预期输出、用例入口。在上述隔离服务上定向运行 3/3 成功、0 failed、0 skipped;#247 尚未合入,完整 MOTR suite/集成 CI 本次未运行。测试证据
2f9726f3;上述三个文件包含可复核的 SQL、预期输出及失败原子性断言。total=1 success=1 failed=0 skipped=0;随后--repeat 2为total=2 success=2 failed=0 skipped=0。执行前脚本参数错误已在本地修正,不属于产品失败,修正后的 3 次结果如上。测试结论
测试通过。