Repository navigation
Description
Description
CREATE DATABASE ... CLONE aborts the entire database clone when the source database contains a readable external table. The implementation enumerates the external relation as a source table, sends it through the base-table clone path, and returns is not BASE TABLE; ordinary tables in the same database are therefore not cloned either.
The documented CLONE restrictions do not list external tables, and the documentation states that database CLONE copies table/database structure, data, and related metadata. External data itself does not need to be copied, but an external table should not make the whole database unclonable: its definition/metadata should be recreated, or it should be skipped consistently and explicitly if that is the intended product contract.
Environment
- Branch:
main - Commit:
1d7b6311ce91df0968da435bb405f3d68137c595 - Deployment: standalone
mo-service, isolated local data directory, MySQL protocol port 6002
Steps to reproduce
Create a small CSV on the MatrixOne host:
printf '1,alpha\n2,beta\n' > /tmp/mo_clone_ext_probe.csvRun:
DROP DATABASE IF EXISTS clone_ext_src;
DROP DATABASE IF EXISTS clone_ext_dst;
CREATE DATABASE clone_ext_src;
CREATE TABLE clone_ext_src.control_t(id INT PRIMARY KEY);
INSERT INTO clone_ext_src.control_t VALUES (1);
CREATE EXTERNAL TABLE clone_ext_src.ext_t(
id INT,
payload VARCHAR(20)
)
INFILE{
'filepath'='/tmp/mo_clone_ext_probe.csv',
'format'='csv'
}
FIELDS TERMINATED BY ',';
-- Passing source control: returns two rows.
SELECT * FROM clone_ext_src.ext_t ORDER BY id;
CREATE DATABASE clone_ext_dst CLONE clone_ext_src;Actual behavior
The database clone fails:
ERROR 20101 (HY000): internal error: clone_ext_src.ext_t is not BASE TABLE
The target database does not exist after the failure, so the statement rolls back atomically, but the ordinary table control_t is not cloned either.
Expected behavior
An external table must not abort cloning every supported object in the database. Database CLONE should either:
- recreate the external table definition/metadata in the target while leaving the external data in place; or
- skip external tables consistently with the snapshot/PITR bulk-restore policy and clearly document/report that limitation without failing the whole database clone.
Stability and controls
- Reproducer: 3/3 independent source/target database pairs failed with the same
is not BASE TABLEerror. - Control: a database containing only
control_tcloned successfully and the target contained the expected row. - Source validity: each source external table returned exactly two rows before the clone and remained readable after the failure.
- Failure atomicity/data check: each failed target database count was
0; source data was unchanged; the service remained responsive.
Evidence
Three-run output excerpt:
control_clone_rows = 1
run1_source_ext_rows = 2
ERROR 20101 (HY000): internal error: clone_ext_src_1.ext_t is not BASE TABLE
run1_target_db_count = 0
run1_source_still_readable = 2
run2_source_ext_rows = 2
ERROR 20101 (HY000): internal error: clone_ext_src_2.ext_t is not BASE TABLE
run2_target_db_count = 0
run2_source_still_readable = 2
run3_source_ext_rows = 2
ERROR 20101 (HY000): internal error: clone_ext_src_3.ext_t is not BASE TABLE
run3_target_db_count = 0
run3_source_still_readable = 2
service_alive = 1
Code analysis
pkg/frontend/clone_database_source.go::collectCloneDatabaseSourcecollects all relations returned bygetTableInfos, including external tables.pkg/frontend/clone.go::handleCloneDatabaseWithSourceskips only views in its general loop and calls the table-clone path for every other relation.pkg/sql/plan/build_ddl.goexplicitly rejectscatalog.SystemExternalRelin theCREATE TABLE ... LIKE/CLONEpath with%s.%s is not BASE TABLE.- In contrast, snapshot/PITR bulk-restore code explicitly skips external tables because their data is stored outside MatrixOne.
The likely defect is missing external-table routing in database CLONE: it neither recreates/skips the metadata nor excludes the relation before invoking base-table CLONE.
Regression coverage
Add a BVT under test/distributed/cases/git4data/clone/ that creates one ordinary table and one local-file external table, runs database CLONE, and verifies the documented external-table policy plus successful cloning of the ordinary table. Cover live and snapshot database CLONE if external-table behavior is intended to be identical.
Related
- [Bug]: CREATE TABLE ... CLONE converts a sequence into a writable base table #27050 is related object-type coverage, but it concerns a sequence being converted into a writable base table and is not a duplicate.
- [Bug]: CREATE DATABASE CLONE silently omits stored procedures #27091 concerns stored procedures being omitted and is not a duplicate.
Activity
gouhongshen commentedon Aug 13, 2026
Automated AI triage
This issue requires human involvement and cannot currently be completed independently by the
automated fix loop.
Reason
Requires clone product owners to decide whether database clone recreates external-table metadata or explicitly omits external tables. The human next action is to approve and document one contract.
Evidence
The current clone path treats non-view relations as cloneable base tables, while the issue explicitly offers two incompatible expected behaviors.
Please use this analysis to provide the missing decision, environment, evidence, or ownership
needed before the issue is returned to the AI candidate pool.
gouhongshen commentedon Sep 4, 2026
PR #28146 is trying to fix this issue.
gouhongshen commentedon Sep 5, 2026
PR #28146 has merged and is awaiting manual validation. The issue remains open.
Ariznawlll commentedon Sep 16, 2026
测试版本
main9572bd3311abb16d1df939956408a727bcf83eba原问题验证
在两个 CN 都放置可读 CSV 后,源库包含 2 行可读 external table 和 1 行普通表。连续 3 个独立源/目标库执行
CREATE DATABASE ... CLONE均成功:源 external table 每次返回 2 行,目标库存在且普通表返回 1 行;目标SHOW TABLES仅包含普通表,符合外部表跳过策略。Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
实现 PR 已新增 clone source/权限重映射相关单测;本次不以白盒结果替代部署 SQL 验收。
回归测试
已由 MatrixOne PR #28146 添加
test/distributed/cases/git4data/clone/issue_27103_clone_external_table.sql及 result,覆盖 external table 跳过和普通表克隆。测试证据
PR #28146 文件清单;三轮环境实测均为
source external rows=2、target db=1、control rows=1。测试结论
测试通过。