Repository navigation
Description
Describe the bug
Database-level CLONE and Data Branch database operations incorrectly ignore
queryable user tables when their names match internal-looking names or
prefixes. The create paths silently omit the tables, while
DATA BRANCH DELETE DATABASE can skip the same tables during validation and
delete the database that contains them. Confirmed examples are:
- an ordinary persistent
relkind='r'table named__mo_tmp_user_data; - an ordinary persistent
relkind='r'table named__mo_account_lock; - a user-created, queryable table named
mo_increment_columns.
The tables remain queryable and can be copied correctly with the table-level
Data Branch statement. The database-level create statements nevertheless
return success without creating them in the destination.
Tested at commit 2eb7f523e5a10f352d3e258183ed8440510388de.
Steps to reproduce
drop database if exists g4d_tmp_prefix_branch;
drop database if exists g4d_tmp_prefix_clone;
drop database if exists g4d_tmp_prefix_src;
create database g4d_tmp_prefix_src;
use g4d_tmp_prefix_src;
create table `__mo_tmp_user_data` (
id int primary key,
note varchar(30)
);
create table `__mo_account_lock` (
id int primary key,
note varchar(30)
);
create table `mo_increment_columns` (
id int primary key,
note varchar(30)
);
insert into `__mo_tmp_user_data` values (1, 'persistent-user-row');
insert into `__mo_account_lock` values (2, 'ordinary-lock-name');
insert into `mo_increment_columns` values (3, 'ordinary-auto-name');
select relname, relkind
from mo_catalog.mo_tables
where account_id = 0
and reldatabase = 'g4d_tmp_prefix_src'
and relname in (
'__mo_tmp_user_data',
'__mo_account_lock',
'mo_increment_columns'
);
data branch create table direct_branch
from `__mo_tmp_user_data`;
data branch create table direct_lock
from `__mo_account_lock`;
data branch create table direct_auto
from `mo_increment_columns`;
select * from direct_branch;
select * from direct_lock;
select * from direct_auto;
data branch create database g4d_tmp_prefix_branch
from g4d_tmp_prefix_src;
create database g4d_tmp_prefix_clone
clone g4d_tmp_prefix_src;
select reldatabase, relname, relkind
from mo_catalog.mo_tables
where account_id = 0
and reldatabase in (
'g4d_tmp_prefix_branch',
'g4d_tmp_prefix_clone'
)
and relname in (
'__mo_tmp_user_data',
'__mo_account_lock',
'mo_increment_columns'
);
-- Deletion-validation comparison.
data branch create database g4d_delete_normal
from g4d_tmp_prefix_src;
create table g4d_delete_normal.ordinary_keep(
id int primary key,
note varchar(30)
);
insert into g4d_delete_normal.ordinary_keep values (10, 'must-remain');
data branch delete database g4d_delete_normal;
data branch create database g4d_delete_filtered
from g4d_tmp_prefix_src;
create table g4d_delete_filtered.`__mo_tmp_user_keep`(
id int primary key,
note varchar(30)
);
insert into g4d_delete_filtered.`__mo_tmp_user_keep`
values (11, 'must-remain');
data branch delete database g4d_delete_filtered;
select count(*)
from mo_catalog.mo_database
where datname = 'g4d_delete_filtered';Actual behavior
The first two source tables are normal persistent relations:
__mo_tmp_user_data r
__mo_account_lock r
All three table-level branches contain the expected rows:
1 persistent-user-row
2 ordinary-lock-name
3 ordinary-auto-name
Both database-level statements return success, but the destination metadata
query returns no row for any of the three tables.
The Data Branch database path was reproduced with three independent
destinations. All three silently contained only the other source tables.
For deletion, the ordinary ordinary_keep table correctly prevents
DATA BRANCH DELETE DATABASE, and both the database and row remain. Replacing
that table with the normal persistent relation __mo_tmp_user_keep
(relkind='r') changes the result: the delete statement succeeds and the
database count becomes zero. The prefix case was reproduced with three
independent branch databases. The exact names __mo_account_lock and
mo_increment_columns are ignored by the same validation path.
Expected behavior
A database-level copy should not omit a queryable user-created table solely
because its legal name resembles an internal object name. It should distinguish
internal relations using object metadata rather than only the user-visible
name.
At minimum, a database-level statement must not report a complete successful
copy while silently dropping a source base table. The delete statement must
also reject a database that contains any ordinary non-branch table, regardless
of that table's legal name.
Code context
Both database-level paths use collectCloneDatabaseSource, which calls
getTableInfos. buildTableInfoListWhereClause excludes every matching name:
relname not like '__mo_tmp\\_%' escape '\\'The same filter also excludes the exact names mo_increment_columns and
__mo_account_lock. These predicates do not verify that a relation is the
corresponding internal object. Consequently, queryable user tables are removed
from srcTblInfos before cloning begins.
branchDeleteDatabaseTableIDsSQL reuses
buildTableInfoListWhereClause. As a result, the same user tables are removed
from the set passed to validateActiveBranchChildTableIDs. The validator never
sees them, so database deletion proceeds even though they are ordinary
non-branch tables.
Activity
[-][Bug]: Database CLONE and DATA BRANCH silently skip persistent tables named __mo_tmp_*[/-][+][Bug]: Database CLONE and DATA BRANCH silently skip persistent tables with internal-looking names[/+][-][Bug]: Database CLONE and DATA BRANCH silently skip persistent tables with internal-looking names[/-][+][Bug]: Database Data Branch and CLONE filter persistent user tables by internal-looking names[/+]fix: preserve user tables with internal-looking names (#26219)
VioletQwQ-0 commentedon Jul 29, 2026
PR #26219 merged as
a7f667b08f9760fd8bce048b7db13948adacce2c(reviewed head6a801415130fd7afb9339985352115b17733205f). The issue-linked regression and replacement exact-head CI passed before merge.QA handoff on main
f6dab28046d70412cec132f0068840896852101c:Pass: all persistent user objects are preserved without leaking genuine internal objects. Fail: user-table omission or internal-object inclusion.
Ariznawlll commentedon Jul 29, 2026
已在最新
main分支完成验证。测试版本:
52ea9f874f492c368a20efef16b46ab8ced2de37测试拓扑:Proxy + 2 CN
重复次数:3 轮
测试过程:
测试结果:
结论:该问题在上述最新 main commit 上验证通过。
Ariznawlll commentedon Jul 30, 2026
已在
main@0ebba1c0c96bbcf0ff4091236e10df7b97e24a0c补充完成黑盒和白盒验证。黑盒验证:
__mo_tmp_*、__mo_account_lock、mo_increment_columns等 internal-looking 用户表。DATA BRANCH DELETE DATABASE,要求拒绝删除并检查数据库和行仍存在。结果:该 case
32/32条 SQL/断言通过;本轮 Data Branch 全集13/13case、280/280条 SQL/断言通过。白盒验证:
Unhappy path / 对象过滤边界:
DATA BRANCH DELETE DATABASE,操作必须被拒绝。结论:系统现在按 relation metadata 区分内部对象和同名用户对象,复制与删除保护路径均验证通过;黑盒回归已加入 motr#69。
Ariznawlll commentedon Jul 30, 2026
Unhappy Path / 对象误过滤专项验证
测试版本:
main@0ebba1c0c96bbcf0ff4091236e10df7b97e24a0c专项使用名称看起来像内部对象、但 metadata 为普通用户表的对象:
验证内容:
DATA BRANCH DELETE DATABASE,必须拒绝删除。结果:用户表没有被误过滤;数据库删除被正确拒绝且数据保留;真正内部对象仍按系统对象处理。专项用例
32/32条 SQL/断言通过。测试结论
测试通过。
test: isolate cyclic foreign key regression (#27647)
fix: preserve user tables with internal-looking names (matrixorigin#2…
test: isolate cyclic foreign key regression (matrixorigin#27647)
fix: preserve user tables with internal-looking names (matrixorigin#2…
test: isolate cyclic foreign key regression (matrixorigin#27647)
fix: preserve user tables with internal-looking names (matrixorigin#2…
test: isolate cyclic foreign key regression (matrixorigin#27647)