Repository navigation
Description
Description
TRUNCATE TABLE is accepted for a MongoDB external table, returns success, but does not fail closed and does not change the mapped source or report that the operation is unsupported.
Environment
- Branch:
main - Commit:
71031d0e9e45920821d71ce03f519181d346e669 - Deployment: TKE, MatrixOne
3 CN / 1 DN / 3 Log, MongoDB8.0.12three-member ReplicaSet,ENGINE=MONGODB, explicit schema,read_concern=majority,read_preference=primary - Namespace:
mo-search-commit-71031d0e9-20260819 - Related feature: [Feature Request]: Support MongoDB as a native external table source #26229
Steps to reproduce
- Create a MongoDB connection and an explicit MongoDB external table mapped to a collection containing four documents.
- Verify
SELECT COUNT(*) FROM mongo_events_extreturns4. - Execute:
TRUNCATE TABLE mongo_events_ext;- Query the external table again.
Actual behavior
TRUNCATE TABLE returns success (status=0), but the external table still returns four rows. The mapped MongoDB collection remains unchanged.
Expected behavior
MongoDB external tables are read-only. TRUNCATE TABLE must be rejected with the same stable external-table read-only error as direct INSERT, UPDATE, DELETE, and REPLACE, and the mapping must remain queryable.
Stability and controls
- Reproducer: 3/3 rounds, each returned success and then
COUNT(*)=4. - Control: ordinary MatrixOne table with two rows returned
COUNT(*)=0afterTRUNCATE TABLE. - Other direct DML controls:
INSERT,UPDATE,DELETE, andREPLACEwere rejected withERROR 20301. - Post-failure state: external mapping remained queryable and source data was unchanged.
Evidence
TKE terminal output was captured during the run; the test design report records the three rounds and control result in the continued execution section.
Code analysis
The external-table DML guard covers the tested mutation statements but does not reject TRUNCATE before execution. The exact implementation location requires maintainer confirmation.
Regression coverage
Add a distributed SQL regression for TRUNCATE TABLE on a MongoDB external table, asserting the rejection error and a follow-up source row count.
Related
Source feature issue: #26229.
Activity
fix: reject truncate on MongoDB external tables (#27617)
Ariznawlll commentedon Aug 28, 2026
最新 main 已跑真实本地 MongoDB ReplicaSet E2E(SCRAM、majority read、只读源用户):TRUNCATE 被拒绝为 external-table read-only 错误,随后外表仍能读取原始 5 行;完整 [Verify Go package graph]
go package graph verification failed (attempt 1/3), retrying...
go package graph verification failed (attempt 2/3), retrying...
go package graph verification failed (attempt 3/3), retrying...
go package graph verification failed after 3 attempts 退出码 0。单元合同测试连续 3 轮通过。无需 big-data、PITR/snapshot、stability 或 chaos。结论:关闭。
Ariznawlll commentedon Aug 28, 2026
验证基线为 MatrixOne main 28769ff。真实本地 MongoDB ReplicaSet E2E 已完成:SCRAM、majority read、只读源用户下,TRUNCATE 被外表只读保护拒绝,随后外表仍可读取原始 5 行;make test-mongodb-e2e-local 的测试脚本退出码为 0。Mongo E2E 合同测试也连续三轮通过。无需 big-data、PITR/snapshot、stability 或 chaos。结论:关闭。
fix: reject truncate on MongoDB external tables (matrixorigin#27617)
fix: reject truncate on MongoDB external tables (matrixorigin#27617)
fix: reject truncate on MongoDB external tables (matrixorigin#27617)