Agent | grok | grok-4.7
Summary
RESTORE ACCOUNT fails with Error 20301: invalid input: legacy CHECK metadata is not a CREATE TABLE statement on a tenant that has already been restored once. The first in-place restore of a fresh account can succeed. A later restore of that same account fails. RESTORE ACCOUNT ... TO ACCOUNT of a workspace account that already contains CREATE TABLE ... CLONE ... metadata also fails with the same error.
This blocks using account snapshots as a time-travel mechanism: after one successful restore, the account can no longer be restored to another snapshot.
When RESTORE ACCOUNT ... TO ACCOUNT does succeed, table privileges are not preserved. The role still exists, SHOW GRANTS for that role is empty, and a user who held the role can no longer read the table. Losing authorization on restore is a severe failure even when the data rows come back.
Version
Local MatrixOne 8.1.1-149 v4.2.4 (SELECT version()).
What works
Fresh account ws_08acbe57 (a newly created workspace, zero prior restores):
CREATE SNAPSHOT tm_123_self FOR ACCOUNT ws_08acbe57;
RESTORE ACCOUNT ws_08acbe57 {SNAPSHOT = 'tm_123_self'};
This in-place restore succeeded. The tenant database moi still had 527 tables.
CREATE SNAPSHOT tm_123_s1 FOR ACCOUNT ws_08acbe57;
CREATE ACCOUNT tm_123_bak ADMIN_NAME 'root' IDENTIFIED BY 'test-pass';
RESTORE ACCOUNT ws_08acbe57 {SNAPSHOT = 'tm_123_s1'} TO ACCOUNT tm_123_bak;
Copying that fresh account into a new account also succeeded. Both accounts had 527 tables in moi.
What fails
- In-place restore of an account that was itself produced by
RESTORE ... TO ACCOUNT:
CREATE SNAPSHOT tm_123_s2 FOR ACCOUNT tm_123_bak;
RESTORE ACCOUNT tm_123_bak {SNAPSHOT = 'tm_123_s2'};
Result:
ERROR 20301 (HY000): invalid input: legacy CHECK metadata is not a CREATE TABLE statement
- A second in-place restore of the original account, after the first in-place restore had succeeded:
CREATE SNAPSHOT tm_123_s1 FOR ACCOUNT ws_08acbe57;
RESTORE ACCOUNT ws_08acbe57 {SNAPSHOT = 'tm_123_s1'};
Same Error 20301.
- Restoring a snapshot onto a different account than the one named in the snapshot:
RESTORE ACCOUNT tm_123_bak {SNAPSHOT = 'tm_123_s1'};
tm_123_s1 was created FOR ACCOUNT ws_08acbe57. Result:
ERROR 20101 (HY000): internal error: accountName(tm_123_bak) does not match snapshot.accountName(ws_08acbe57)
- On an older workspace account that had already been restored (
ws_09e1f518), RESTORE ACCOUNT ... TO ACCOUNT failed immediately with the same Error 20301. CREATE SNAPSHOT ... FOR ACCOUNT itself succeeded.
Metadata involved
For ws_08acbe57, mo_catalog.mo_tables.rel_createsql contains CHECK on:
information_schema.files, partitions, tables, views
- 9 tables in the tenant database
moi
One of those tenant rows is not a normal CREATE TABLE. Its stored SQL starts with:
create table `moi`.`structured_load_runtime_checkpoint` clone `moi`.`structured_load_runtime_checkpoint` ...
pkg/sql/plan/build_ddl.go recoverLegacyChecks parses Createsql when it contains CHECK and the structured constraint list is empty. It returns 20301 unless the statement is a CREATE TABLE. A stored CREATE TABLE ... CLONE ... statement, and the information_schema views, take that path during RESTORE ACCOUNT.
Privileges are dropped
On the same server, a small account was restored back onto itself with RESTORE ACCOUNT backup {SNAPSHOT = ...} TO ACCOUNT live. The live account was not dropped. Account id stayed the same. The table rows returned to the snapshot contents.
Before the write-back the account had:
CREATE ROLE r1;
GRANT SELECT ON TABLE app_db.t TO r1;
CREATE USER u1 IDENTIFIED BY '...';
GRANT r1 TO u1;
After the write-back:
r1 still existed.
SHOW GRANTS FOR r1 returned no rows.
u1 selecting app_db.t failed with ERROR 20101 (HY000): internal error: do not have privilege to execute the statement.
Table id changed across this restore. That id change is expected. The privilege disappearing is not.
Expected
RESTORE ACCOUNT of a tenant should be repeatable. A successful restore must not leave CHECK or CLONE metadata that makes the next restore fail.
CREATE TABLE ... CLONE ... stored in rel_createsql should not be parsed as legacy CHECK metadata.
- Account restore should not depend on
information_schema view definitions being CREATE TABLE statements.
- Roles, users, and table grants that exist in the snapshot must still authorize the same tables after restore.
Database and table ids changing after CREATE DATABASE ... CLONE or RESTORE ACCOUNT is expected and is not part of this bug.
Repro notes
The failing statements were run as the cluster root user against 127.0.0.1:6001. Temporary snapshots and the temporary account tm_123_bak were dropped after the test. The original workspace account was left in place.
Summary
RESTORE ACCOUNTfails withError 20301: invalid input: legacy CHECK metadata is not a CREATE TABLE statementon a tenant that has already been restored once. The first in-place restore of a fresh account can succeed. A later restore of that same account fails.RESTORE ACCOUNT ... TO ACCOUNTof a workspace account that already containsCREATE TABLE ... CLONE ...metadata also fails with the same error.This blocks using account snapshots as a time-travel mechanism: after one successful restore, the account can no longer be restored to another snapshot.
When
RESTORE ACCOUNT ... TO ACCOUNTdoes succeed, table privileges are not preserved. The role still exists,SHOW GRANTSfor that role is empty, and a user who held the role can no longer read the table. Losing authorization on restore is a severe failure even when the data rows come back.Version
Local MatrixOne
8.1.1-149 v4.2.4(SELECT version()).What works
Fresh account
ws_08acbe57(a newly created workspace, zero prior restores):CREATE SNAPSHOT tm_123_self FOR ACCOUNT ws_08acbe57; RESTORE ACCOUNT ws_08acbe57 {SNAPSHOT = 'tm_123_self'};This in-place restore succeeded. The tenant database
moistill had 527 tables.Copying that fresh account into a new account also succeeded. Both accounts had 527 tables in
moi.What fails
RESTORE ... TO ACCOUNT:CREATE SNAPSHOT tm_123_s2 FOR ACCOUNT tm_123_bak; RESTORE ACCOUNT tm_123_bak {SNAPSHOT = 'tm_123_s2'};Result:
CREATE SNAPSHOT tm_123_s1 FOR ACCOUNT ws_08acbe57; RESTORE ACCOUNT ws_08acbe57 {SNAPSHOT = 'tm_123_s1'};Same
Error 20301.RESTORE ACCOUNT tm_123_bak {SNAPSHOT = 'tm_123_s1'};tm_123_s1was createdFOR ACCOUNT ws_08acbe57. Result:ws_09e1f518),RESTORE ACCOUNT ... TO ACCOUNTfailed immediately with the sameError 20301.CREATE SNAPSHOT ... FOR ACCOUNTitself succeeded.Metadata involved
For
ws_08acbe57,mo_catalog.mo_tables.rel_createsqlcontainsCHECKon:information_schema.files,partitions,tables,viewsmoiOne of those tenant rows is not a normal
CREATE TABLE. Its stored SQL starts with:pkg/sql/plan/build_ddl.gorecoverLegacyChecksparsesCreatesqlwhen it containsCHECKand the structured constraint list is empty. It returns 20301 unless the statement is aCREATE TABLE. A storedCREATE TABLE ... CLONE ...statement, and theinformation_schemaviews, take that path duringRESTORE ACCOUNT.Privileges are dropped
On the same server, a small account was restored back onto itself with
RESTORE ACCOUNT backup {SNAPSHOT = ...} TO ACCOUNT live. The live account was not dropped. Account id stayed the same. The table rows returned to the snapshot contents.Before the write-back the account had:
After the write-back:
r1still existed.SHOW GRANTS FOR r1returned no rows.u1selectingapp_db.tfailed withERROR 20101 (HY000): internal error: do not have privilege to execute the statement.Table id changed across this restore. That id change is expected. The privilege disappearing is not.
Expected
RESTORE ACCOUNTof a tenant should be repeatable. A successful restore must not leave CHECK or CLONE metadata that makes the next restore fail.CREATE TABLE ... CLONE ...stored inrel_createsqlshould not be parsed as legacy CHECK metadata.information_schemaview definitions beingCREATE TABLEstatements.Database and table ids changing after
CREATE DATABASE ... CLONEorRESTORE ACCOUNTis expected and is not part of this bug.Repro notes
The failing statements were run as the cluster
rootuser against127.0.0.1:6001. Temporary snapshots and the temporary accounttm_123_bakwere dropped after the test. The original workspace account was left in place.