matrixorigin / matrixone

Hyperconverged cloud-edge native database
https://docs.matrixorigin.cn/en
Apache License 2.0
1.77k stars 275 forks source link

[Bug]: cluster level snapshot restore subscription table to new account error. #17308

Closed Ariznawlll closed 2 months ago

Ariznawlll commented 3 months ago

Is there an existing issue for the same bug?

Branch Name

main

Commit ID

580f61a

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

image

Expected Behavior

No response

Steps to Reproduce

-- restore to new account
drop account if exists acc03;
create account acc03 admin_name = 'test_account' identified by '111';
-- @session:id=1&user=acc01:test_account&password=111
drop database if exists test04;
create database test04;
use test04;
drop table if exists t1;
create table t1(a int primary key,b int, constraint `c1` foreign key fk1(b) references t1(a));
show tables;
show create table t1;
insert into t1 values (1,1);
insert into t1 values (2,1);
insert into t1 values (3,2);
select * from t1;
-- @session

drop snapshot if exists sp105;
create snapshot sp105 for cluster;

-- @session:id=1&user=acc01:test_account&password=111
drop publication if exists pub10;
create publication pub10 database test04 account acc02 comment 'publish test03';
-- @ignore:2,6
select * from mo_catalog.mo_pubs;
-- @session

-- @session:id=2&user=acc02:test_account&password=111
drop database if exists sub09;
create database sub09 from acc01 publication pub10;
show databases;
use sub09;
select * from t1;
-- @session

restore account acc02 from snapshot sp105 to account acc03;

-- @session:id=2&user=acc02:test_account&password=111
-- @ignore:2,6
show databases;    -->restore是将acc02恢复到新租户acc03,这个时候acc02的数据不变,acc03的数据是恢复的快照对应的数据,但是现在acc02的数据也没了
-- @session

Additional information

No response

Ariznawlll commented 3 months ago

另一种场景:

image

-- @session:id=1&user=acc01:test_account&password=111 drop database if exists test03; create database test03; use test03; drop table if exists t1; create table t1(a int primary key,b int, constraint c1 foreign key fk1(b) references t1(a)); show tables; show create table t1; insert into t1 values (1,1); insert into t1 values (2,1); insert into t1 values (3,2); select * from t1; -- @session

drop snapshot if exists sp104; create snapshot sp104 for cluster;

-- @session:id=1&user=acc01:test_account&password=111 drop publication if exists pub09; create publication pub09 database test03 account acc02 comment 'publish test03'; -- @session

drop snapshot if exists sp105; create snapshot sp105 for cluster;

-- @session:id=2&user=acc02:test_account&password=111 drop database if exists sub08; create database sub08 from acc01 publication pub09; show databases; use sub08; select * from t1; -- @session

restore account acc01 from snapshot sp104 to account acc03; -->执行完这条sql后acc01的数据还在,acc03的数据为sp104对应的时间戳之前的数据

-- @session:id=2&user=acc02:test_account&password=111 show databases; use sub08; -->acc01发布给acc02的订阅应该还在,但是现在use这个订阅db报错 -- @session

Ariznawlll commented 2 months ago

testing

Ariznawlll commented 2 months ago

commit:d15d6992680af37a66574b4f224ad397a05c8857 情景一:

image

情景二:

image

test done.