Skip to content

[Bug]: MongoDB external table accepts AUTO_INCREMENT and fails at scan time #27347

Closed

Description

@Ariznawlll

Description

MongoDB external-table DDL accepts AUTO_INCREMENT, although the external table contract requires unsupported local sequence attributes to fail closed; scanning then fails at runtime while converting the MongoDB string _id to BIGINT.

Environment

Steps to reproduce

With a valid MongoDB connection, execute:

CREATE EXTERNAL TABLE ext_bad_ai (
  id BIGINT AUTO_INCREMENT MONGODB_PATH '_id'
) ENGINE=MONGODB WITH (
  'connection'='valid_connection',
  'database'='test_db',
  'collection'='events',
  'schema_mode'='explicit'
);
SELECT id FROM ext_bad_ai;

The collection contains string _id values.

Actual behavior

The CREATE EXTERNAL TABLE statement succeeds. The subsequent scan fails with ERROR 20301: MongoDB value at path _id cannot be converted to BIGINT.

Expected behavior

Until sequence semantics are explicitly supported for MongoDB external tables, the DDL must be rejected atomically and must not leave a catalog mapping.

Stability and controls

  • DDL acceptance and runtime behavior reproduced 3/3.
  • The normal MongoDB external table without AUTO_INCREMENT scans successfully.
  • No partial rows were observed after the runtime error.

Evidence

TKE terminal output and the test design report record status=0 for creation and the repeated runtime conversion error.

Code analysis

The DDL preserves AUTO_INCREMENT in SHOW CREATE TABLE but the MongoDB scan treats the mapped value as an ordinary BIGINT; exact ownership of the fail-closed validation requires maintainer confirmation.

Regression coverage

Add a DDL regression asserting that AUTO_INCREMENT on a MongoDB external table is rejected and no table/mapping remains.

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 21, 2026
  5. Ariznawlll commented on Aug 23, 2026

    @Ariznawlll
    CollaboratorAuthor

    已在最新 main(6ff9be9646a6ac43e05ba3063de27b2248bbac62)的 MongoDB connector/endpoint allowlist 配置下验证修复。

    验证内容:

    • 不含 AUTO_INCREMENT 的 MongoDB external table DDL 可正常创建并写入表及 MongoDB mapping 元数据。
    • 含 AUTO_INCREMENT 的 DDL 在创建阶段即被拒绝(ERROR 20105),不会等到扫描时才失败。
    • 拒绝后查询 mo_tables 和 mo_mongodb_tables,均不存在目标表或 mapping 残留;后续会话正常。

    该场景需要受控 MongoDB fixture、凭据和服务端 endpoint allowlist。默认 MOTR 环境按安全策略不提供这些依赖,因此不加入会永久失败的 MOTR 用例;应由带 fixture 的 MongoDB 集成/BVT 环境回归。

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