Repository navigation
Description
Measured while implementing #13854 (SqlDriver.bulkUpdate transaction wrapper). #13854's dispatch owed one reading: does driver-mongodb carry the same shape? This card records the answer, which is "not the same shape, but a related exposure" — filed separately rather than widened into #13854's PR, exactly as that card's scope required.
The reading (measured on origin/main, by symbol)
packages/drivers/driver-mongodb/src/mongodb-driver.ts:
bulkUpdate(:505) is NOTdriver-sql's shape. It does not loop over N awaitedupdate()calls. It mapsupdatesinto abulkOpsarray ofupdateOnedescriptors and issues onecollection.bulkWrite(bulkOps, { session }), then re-reads the affected ids.bulkDelete(:534) is onecollection.deleteMany({ id: { $in: ids } }, { session })— the same "single statement" shape asSqlDriver.bulkDelete, which driver-sql:bulkUpdateis a sequential per-row loop with no transaction — a mid-batch refusal leaves earlier rows committed (driver-turso inherits it viasuper.) #13854 measured and correctly left out of scope.sessionin both comes fromgetSession(options)(:687), which is exactlyoptions.transaction as ClientSession | undefined— the sameoptions.transactionparameterisation the SQL driver uses.
So the per-row autocommit loop #13854 repaired does not exist here. That half of the reading is settled.
Why this is still worth a card
The consequence class may nevertheless be reachable, through a different mechanism. bulkWrite defaults to ordered: true, which stops at the first failing operation — but operations already applied are not undone unless the operation is running inside a transaction. When the caller passes no options.transaction, session is undefined, so a batch refused partway through would leave the earlier updateOne ops applied: the same end state #13340 / #13435 / #13854 closed on the other two drivers, arrived at by a different route.
- Measured (read from the source in this repo): the shapes and the
sessionplumbing described above. - NOT measured, and the reason this is a card rather than a patch: that a mid-batch refusal actually leaves earlier ops applied here. That is standard MongoDB
bulkWritesemantics rather than something observed against this driver, and it was deliberately not driven to a repro — driver-sql:bulkUpdateis a sequential per-row loop with no transaction — a mid-batch refusal leaves earlier rows committed (driver-turso inherits it viasuper.) #13854's scope was explicit thatdriver-mongodbis read-only, measure and report. It needs a real refusal driven through this door before anyone acts on it.
Why the #13854 fix does not simply transfer
⛔ Do not assume the repair is "wrap it in a transaction like the SQL driver". MongoDB multi-document transactions require a replica set (or a sharded cluster) — they are unavailable on a standalone mongod, which is a supported deployment. So an unconditional driver-opened transaction would turn a currently-working call into a hard failure on those deployments. That is a genuine decision, not a mechanical port, which is the other reason this is filed rather than fixed in passing.
Sketch of the option space, for whoever picks this up:
- Open a transaction only when the topology supports one, and document the weaker guarantee elsewhere — declared ≠ enforced, which is the shape this project usually refuses.
- Require the caller to supply a session for atomicity, and say so in the contract — honest, but leaves the bulk door's implied promise unmet by default.
- Decide the bulk door does not promise atomicity on this driver, and record that as an explicit, tested difference rather than an accident.
Related
#13854 (driver-sql, the card this reading was owed to) · #13435 · #13340 (the driver-memory half of the same defect class)
Filed unassigned and unlabelled for triage, per the dispatch's out-of-scope rules.
Generated by Claude Code
Activity
huangyiirene commentedon Sep 2, 2026
Triage (R+89, triage seat, session
session_019kDRpB7D2XzVzkaLp57T5D): graded →pm:on-hold·priority:p2·domain:engine· type Task.findingremoved.Why hold, not queue: the standing maintainer ruling of 2026-08-05 recorded on #5499 freezes defect-repair and semantic-completion investment in
driver-memory/driver-mongodb("driver-mongodb 暂无客户;创业团队集中精力,不铺大"), and its standing triage rule for new cards is verbatim: 「driver-memory / driver-mongodb 族新单照常按落点打domain:engine,但直接挂pm:on-hold引用本单,不入pm:queue」. This card's landing file ispackages/drivers/driver-mongodb/src/mongodb-driver.ts(bulkUpdate), so the rule applies by construction. The freeze's escalation exception (a driver-memory defect that corrupts CI verdicts) does not reach a driver-mongodb atomicity question.What is preserved for the day it restarts: the card's own split — the measured half (single
bulkWrite,sessionfromoptions.transaction) and the unmeasured half (that a mid-batch refusal leaves earlier ops applied here) — plus the three-way option space, of which option 3 (declare and test that the bulk door does not promise atomicity on this driver) is the one that stays inside the freeze's "no investment" letter if a customer ever forces the question.Restart-when: closed #5499
Restart-touch: packages/drivers/driver-mongodb/src/mongodb-driver.ts
(Hold provenance: triage seat grading under the #5499 maintainer ruling, 2026-09-02.)
Generated by Claude Code
objectstack-fleet commentedon Sep 23, 2026
关
not_planned—— 维护者逐张复核 on-hold 卡时同意关闭;MongoDB 驱动在 #5499 的投入冻结之内分诊席(
session_01Tw7jnJinGHvoGSi8aFkhPJ),2026-09-23T10:19Z。维护者 2026-09-23 在分诊会话里逐张复核pm:on-hold卡,对第七组的回复原文:「其他同意」。本卡在那一组里的建议是关闭。读数原样保留,供以后重启时直接取用
driver-mongodb的bulkUpdate不是driver-sql那种逐行自动提交的循环,而是一次collection.bulkWrite(bulkOps, { session }),session来自options.transaction;5502936978记录):其中「声明并测试:本驱动的批量入口不承诺原子性」是唯一不需要事务、也不会让单机 MongoDB 部署失效的那一条。最直接的修法(一律开事务)会让单机部署直接不可用。为什么关
Restart-when:是「[裁决] driver-memory / driver-mongodb 投入冻结 —— 维护者 2026-08-05 口径(跨单锚点) #5499 关闭」。维护者 2026-08-05 的裁定([裁决] driver-memory / driver-mongodb 投入冻结 —— 维护者 2026-08-05 口径(跨单锚点) #5499,「driver-mongodb 暂无客户;创业团队集中精力,不铺大」)至今有效,没有任何迹象要解冻。execute()answer without running the command and without refusing — a declared, NON-optional contract member that no caller can tell apart from "ran and found nothing" #14082 同批关闭。重开条件
#5499 解冻(出现需要 MongoDB 的客户)⇒ 带着上面的读数重开,先补测「未测的一半」,再在选项里择一。
关闭理由:
not_planned,同时摘掉pm:on-hold。Generated by Claude Code