Repository navigation
Description
What happened
RESTORE ACCOUNT <source>{snapshot="..."} TO ACCOUNT <target> restores users, roles, and table data, but table-level privileges retain the source account table object ID. The restored target table has a new object ID, so the restored non-admin user can connect and has the expected current role but cannot read the table.
This makes a cross-account account snapshot restore incomplete for ordinary application users: the data is present, but the restored table permissions no longer authorize access to it.
Environment
- MatrixOne
main:b18cdee19bad80a51ea54789a727aa1753fd0b08 - Fresh isolated two-CN deployment
- Reproduced independently: 3/3
Steps to reproduce
-- In source_account as account admin
CREATE DATABASE snapshot_account_source_db;
CREATE TABLE snapshot_account_source_db.orders (
id INT PRIMARY KEY,
note VARCHAR(32)
);
INSERT INTO snapshot_account_source_db.orders VALUES (1, 'snapshotted');
CREATE ROLE snapshot_reader;
CREATE USER source_reader IDENTIFIED BY '<password>' DEFAULT ROLE snapshot_reader;
GRANT CONNECT ON ACCOUNT * TO snapshot_reader;
GRANT SELECT ON TABLE snapshot_account_source_db.orders TO snapshot_reader;
GRANT snapshot_reader TO source_reader;
-- A fresh source_reader session can read `orders` here.
-- As sys
CREATE SNAPSHOT snapshot_account_before_mutation FOR ACCOUNT source_account;
RESTORE ACCOUNT source_account{snapshot="snapshot_account_before_mutation"}
TO ACCOUNT target_account;Connect as target_account#source_reader using the restored password and run:
SELECT current_role();
SELECT COUNT(*) FROM snapshot_account_source_db.orders;Actual behavior
The connection succeeds and current_role() returns snapshot_reader, but the SELECT fails with:
internal error: do not have privilege to execute the statement
The issue is reproducible with the following catalog relationship in every run:
source mo_role_privs.obj_id (SELECT on orders) = source orders rel_id = A
target restored mo_role_privs.obj_id = A
target restored orders rel_id = B
A and B are different. The privilege row was copied with the source table object ID instead of being rebound to the restored target table object ID.
Expected behavior
After cross-account account snapshot restore, roles and table-level grants should authorize the restored users against the restored target tables. The restore path should remap table-scoped privilege object IDs to the corresponding target objects, or otherwise preserve equivalent access semantics.
Control checks
- The source reader can read the source table before snapshot creation.
- A new source reader connection after snapshot creation can still read the source table.
- The restored target account contains the snapshotted table data.
- The restored user and role exist and the restored session selects
snapshot_readeras its current role. - A target-only user and target-only table are removed by the account restore as expected.
These controls isolate the failure to the table-grant object mapping during cross-account account snapshot restore.
Activity
Ariznawlll commentedon Aug 9, 2026
测试版本
main08770e1beeb23239c91165492f2fe85243a3c66a原问题验证
源账号中创建带表级 SELECT grant 的 reader,创建 account snapshot 后恢复到已存在目标账号。恢复后的目标 reader 连续 3/3 保持
snapshot_reader,并可读取订单表的COUNT=1,SUM(id)=1。Happy Path 覆盖
1,1数据。Unhappy Path 覆盖
target_only_db与用户;恢复后该数据库查询返回1049 Unknown database,证明 restore 覆盖了目标账号旧状态。白盒验证
不适用:问题本身是跨账号控制面和目录对象映射,使用真实 snapshot/restore 验证比 mock 更合适。
回归测试
已加入 motr PR #85:
suites/04_snapshot_pitr/t/issue_26640_restore_table_grants.test。该 suite 已配置独占执行;新 case 3 轮通过,完整 snapshot suite 为92/92成功。测试证据
./motr --suite 04_snapshot_pitr:92/92 成功。测试结论
测试通过。
test: isolate cyclic foreign key regression (#27647)
test: isolate cluster restore from shared issue tests (#28019)
test: isolate cyclic foreign key regression (matrixorigin#27647)
test: isolate cluster restore from shared issue tests (matrixorigin#2…
test: isolate cyclic foreign key regression (matrixorigin#27647)
test: isolate cluster restore from shared issue tests (matrixorigin#2…
test: isolate cyclic foreign key regression (matrixorigin#27647)
test: isolate cluster restore from shared issue tests (matrixorigin#2…