Skip to content

[Bug]: TRUNCATE succeeds without effect on MongoDB external table #27346

Closed

Description

@Ariznawlll

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

Steps to reproduce

  1. Create a MongoDB connection and an explicit MongoDB external table mapped to a collection containing four documents.
  2. Verify SELECT COUNT(*) FROM mongo_events_ext returns 4.
  3. Execute:
TRUNCATE TABLE mongo_events_ext;
  1. 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(*)=0 after TRUNCATE TABLE.
  • Other direct DML controls: INSERT, UPDATE, DELETE, and REPLACE were rejected with ERROR 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

  1. added
    kind/bug
    on Aug 19, 2026
  2. added this to the MO-202608 milestone on Aug 19, 2026
  3. added theissue type on Aug 19, 2026
  4. added
    ai-easy
    on Aug 27, 2026
  5. Ariznawlll commented on Aug 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    最新 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。结论:关闭。

  6. Ariznawlll commented on Aug 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    验证基线为 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。结论:关闭。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions