You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The explicit MongoDB pipeline path rejects $sort and $unwind, although MatrixOne issue #27536 lists both stages as initial aggregation-stage candidates.
Environment
Host: TKE node 129
Namespace: mo-search-commit-4fdb9e916-20260907
MatrixOne image: commit-4fdb9e916
Topology: 3 CN / 1 DN / 3 Log / 2 Proxy
MongoDB: 8.0.12, 3-member rs0
Source fixture: mongodb_cov_4fdb.events
Reproduction
Both statements were executed three times in the target namespace:
ERROR 20301 (HY000): invalid input: MongoDB pipeline stage is not allowed
Result: $sort 3/3 rejected; $unwind 3/3 rejected.
The current implementation's allowedUserPipelineStages map contains neither stage, while the validator has stage-specific handling for both. The positive controls $match, $project, $set, $addFields, $unset, $group, $limit, $skip, and $count execute successfully in the same environment.
Expected result
Please confirm and implement the intended contract for #27536. If $sort and $unwind remain in the initial candidate scope, valid read-only forms should be accepted and streamed through MongoDB aggregate; unsafe forms should continue to be rejected by the allowlist and resource checks. If they are intentionally out of scope, please update the issue/design documentation and acceptance matrix explicitly.
Safety checks
No MongoDB source data was modified.
The external-table baseline remained COUNT(*) = 5, SUM(measurement) = 74.
Target namespace pods remained Running with restart count 0.
Activity
fix(mongodb): allow sort and unwind pipeline stages (#28344)
Ariznawlll commentedon Sep 8, 2026
最新 main(commit f72ca9e)本地验证:执行
mo-cgo-test ./test/mongodb -run TestMongoDBLocalE2E -count=1 -p=1,MongoDB E2E runner 的端口规划、契约用例及explicit-sort-and-unwind-pipeline测试均通过(4.165s);源码契约覆盖$sort/$unwind的合法管线和非法参数拒绝。当前本机没有可用 MongoDB ReplicaSet,且本地 Docker Mongo/MO 依赖未处于可运行状态,因此未执行真实外部 MongoDB 连接、cursor 和__mo_query数据校验。结论:#28344 已在当前 main,代码级回归通过;真实 MongoDB E2E 仍待可用服务后复测,暂不关闭。Ariznawlll commentedon Sep 8, 2026
在最新官方 main
f72ca9efbeb3a7c673701e4a135cc6670c33cfde完成修复回归:$sort、$unwind各连续 3/3 通过;同时验证 32 sort fields 成功/33 拒绝、199 unwind path segments 成功/200 拒绝、16 stages 成功/17 拒绝。该问题在此 SHA 上未再复现。证据见 Ariznawlll/mo-test-reports#26,commitc2152ec。Ariznawlll commentedon Sep 8, 2026
测试版本
main585a38efd152fadf216c8675b7b997a35ca8deb19e20c75f522037c7bc08ed0ff0d19ed8b449fdd44dfa553083e018df70ad6bee原问题验证
按 Issue 原始查询分别执行:
$sort与$unwind各连续执行 3 次,共 6/6 返回5;未再返回pipeline stage is not allowed。Happy Path 覆盖
$sort:{site_id:1}:3/3 返回5。$unwind:"$site_id":3/3 返回5。$sort:{_id:-1} + $limit:1返回最大_id=64b000000000000000000005。$set构造双元素数组后$unwind返回10行。$unwindoptions object(path/includeArrayIndex/preserveNullAndEmptyArrays)返回5行。5;199 段 unwind path 可执行;16 stages 返回1。explicit-sort-and-unwind-pipeline通过;完整官方 MongoDB E2E 为 26/26 PASS。Unhappy Path 覆盖
$sortdirection 为0按格式拒绝。$的 unwind path 按格式拒绝。$out、跨 collection$lookup、$function和未知 stage 均 fail-closed 拒绝。COUNT=5, SUM(measurement)=74。open=135, close=135,poolchecked_out=0;Mongo 容器RestartCount=0、OOMKilled=false;MatrixOne 日志未见 panic、fatal、OOM、越界或段错误。白盒验证
执行:
结果:PASS,
ok github.com/matrixorigin/matrixone/pkg/sql/mongodb。覆盖 sort/unwind 正常解析、非法格式、安全阶段拒绝及 plan revalidation fail-closed。回归测试
39225f5fbc63b44a190cdd43f954ee07d78e6cdc,PR fix(mongodb): allow sort and unwind pipeline stages #28344。explicit-sort-and-unwind-pipeline,包含 string/options unwind 形式和非法 sort/unwind。TestParseUserQueryAcceptsSortAndUnwind及对应拒绝/重校验测试。测试证据
测试结论
测试通过。
fix(mongodb): allow sort and unwind pipeline stages (matrixorigin#28344)
fix(mongodb): allow sort and unwind pipeline stages (matrixorigin#28344)
fix(mongodb): allow sort and unwind pipeline stages (matrixorigin#28344)