Skip to content

[Bug]: MongoDB conversion failures do not update conversion error metric #28341

Closed

Description

@Ariznawlll

Summary

MongoDB external-table conversion failures are returned to the client, but mo_mongodb_conversion_errors_total does not increase. This makes the conversion-error metric unable to reflect a real strict BSON-to-MatrixOne conversion failure.

Environment

  • Namespace: mo-search-commit-4fdb9e916-20260907 on TKE host 129
  • MatrixOne image: commit-4fdb9e916
  • Topology: 3 CN / 1 DN / 3 Log / 2 Proxy
  • MongoDB: 8.0.12, 3-member rs0
  • Fixture: mongodb_cov_4fdb.events_aggregate

Reproduction

SELECT device_id,event_count,avg_measurement
FROM mongodb_cov_4fdb.events_aggregate
WHERE __mo_query = '{"pipeline":[{"$project":{"_id":0,"device_id":1,"event_count":{"$literal":"bad"},"avg_measurement":{"$literal":1.5}}}]}';

The query was executed three times and each run returned:

ERROR 20301 (HY000): invalid input: MongoDB value at path event_count cannot be converted to BIGINT

After the failures, all CN metric endpoints showed:

mo_mongodb_conversion_errors_total 0
mo_mongodb_cursor_events_total{event="open"} = mo_mongodb_cursor_events_total{event="close"}
mo_mongodb_pool_checked_out_connections 0

Expected result

Please increment the conversion-error metric for business BSON conversion failures, or explicitly document that this metric only counts tolerated/limited conversion errors and provide a separate metric for strict conversion failures. The metric should remain bounded and must not expose query values or credentials.

Safety checks

  • Cursor open/close counts matched and the checked-out connection gauge returned to zero.
  • External-table baseline remained COUNT(*) = 5, SUM(measurement) = 74.
  • No MongoDB source data was modified.

Activity

  1. added
    kind/bug
    on Sep 7, 2026
  2. added theissue type on Sep 7, 2026
  3. Ariznawlll commented on Sep 8, 2026

    @Ariznawlll
    CollaboratorAuthor

    已在最新官方 main f72ca9efbeb3a7c673701e4a135cc6670c33cfde 本地复核:strict 转换查询按预期返回转换错误,但 conversion_errors_total 为 before=26、after=26,仍未增长;同轮 try_null 转换错误指标可从 25 增到 26。结果与当前 issue 描述一致。逐项证据见 Ariznawlll/mo-test-reports#26,commit c2152ec。

  4. Ariznawlll commented on Sep 8, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:585a38efd152fadf216c8675b7b997a35ca8deb1
    • 部署方式:macOS arm64,本地单进程 1 CN / 1 TN / 1 Log;MongoDB 8.0.12 单节点 ReplicaSet
    • 测试日期:2026-09-08

    原问题验证

    strict BSON-to-BIGINT 转换错误按预期返回,但 mo_mongodb_conversion_errors_total 仍为 before=26, after=26,未增长。

    Happy Path 覆盖

    1. 相邻 try_null 转换错误的指标由 25 -> 26,证明采集和读取路径有效。
    2. strict 查询返回预期转换错误,没有 panic;后续普通扫描仍可用。

    Unhappy Path 覆盖

    1. strict 转换失败未计入 conversion error metric,原问题仍存在。

    白盒验证

    当前 converter 仅在 try_null 分支增加该 counter;strict 分支直接返回错误,和运行结果一致。

    回归测试

    同 SHA 官方 E2E 26/26;扩展矩阵 157 PASS / 1 FAIL,唯一失败即本 Issue。

    测试证据

    扩展矩阵与相关 Issue 汇总

    测试结论

    测试不通过。

  5. added
    ai-easy
    on Sep 10, 2026
  6. added this to the MO-202609 milestone on Sep 23, 2026
  7. Ariznawlll commented on Oct 9, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:官方 main
    • commit:dca6ffc2bf21036627b221b67f05943fbe458cf0
    • 部署方式:独立本地单 CN MatrixOne、MongoDB 8.0.12 单节点 ReplicaSet、真实 Mongo 外表和 CN metrics endpoint
    • 测试日期:2026-10-09

    原问题验证

    Mongo 源文档中把字符串 "bad" 投影到 BIGINT 外表列,在 strict 转换模式下查询返回预期转换错误,同时 mo_mongodb_conversion_errors_total 每次增加 1。三次独立 E2E 运行均通过;同一轮连续三次 strict 失败可观察到计数 0→1→2→3。这与此前 strict 报错但计数不增长的复现结果不同。

    Happy Path 覆盖

    1. 正常文档扫描仍成功,源集合 5 条文档未变化;正常扫描不增加转换错误计数。
    2. try_null 模式继续累计错误,计数从 3 增至 8;验证修复 strict 分支没有破坏既有容错计数。

    Unhappy Path 覆盖

    1. strict 非法类型输入均返回转换错误且逐次递增指标;没有 panic 或吞掉错误。
    2. 无效选择器不触发转换计数;游标打开/关闭数均为 6、checked-out 连接为 0,未见失败路径资源残留。

    白盒验证

    聚焦 Go UT TestConverterConversionErrorMetricCountsStrictAndTryNull 在同一 main 上重复 3 次通过;它分别断言 strict/try_null 分支的计数行为。测试源码。

    回归测试

    此项不加入默认 MOTR:公开 SQL 的 Mongo 外表测试必须有已授权 Mongo ReplicaSet、外部认证配置和 CN metrics endpoint;默认 MOTR 环境没有这些前提。把 SQL 占位文件标记 skip 不会覆盖指标缺陷。保留 MatrixOne 聚焦 UT 和专用 Mongo E2E 作为实际回归层。通用 Mongo E2E 中另有 JSON cast 预期差异,与本次指标用例无关;不宣称通用套件全绿。

    测试证据

    • 聚焦 UT 及断言源码
    • 本次三轮独立 E2E 的指标序列、返回错误、游标/连接平衡检查;原先不增长的旧 main 证据见本 issue 既有评论。

    测试结论

    测试通过。

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