-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When issuing a bulkWrite with errorsOnly:true and the operation goes through the two-phase write (write_ops/write_without_shard_key_util.cpp) without shard key path (because the filter doesn’t contain the shard key and the write requires an upsert), the server returns a cursor containing per-item success reply items. This violates the contract of errorsOnly:true, which should suppress non-error per-item replies.
This was observed on the two-phase/no-shard-key upsert path (mongos orchestrated). Single-phase writes (targetable to a single shard), and unsharded collections, honor errorsOnly:true (no success items returned).
Impact:
- Client libraries receive unexpected reply items, increasing network/CPU overhead.
- Drivers that assume errorsOnly:true suppresses success items (e.g., Java driver) assert/fail on the unexpected cursor contents, surfacing exceptions to applications despite successful writes.
Root cause analysys:
The response comes from write_without_shard_key::runTwoPhaseWriteProtocol (line 615), which internally:
1. When it performs an upsert, calls constructUpsertResponse at write_without_shard_key_util.cpp#L366-L372.
2. constructUpsertResponse always builds a full response with all the details for BulkWrite operations, regardless of whether getErrorsOnly is set
Then when this response is parsed in bulk_write_exec.cpp, it's used as-is without filtering.
In contrast, when handling empty responses in bulk_write_exec.cpp (lines 628-634), the code checks getErrorsOnly:
if (!bulkWriteOp.getClientRequest().getErrorsOnly()) {
items.push_back(BulkWriteReplyItem(0));
}
- blocks
-
JAVA-6002 Restore assertion for verbose results
-
- Needs Triage
-
- is related to
-
JAVA-6001 Remove assertion for verbose results
-
- Needs Triage
-
- related to
-
SERVER-113026 Set nModified for bulk write updateOne without shard key reply item
-
- Needs Scheduling
-