Skip to content

Commit 155def7

Browse files
RUST-2304 Add workarounds for bulk write server bugs (#1551)
1 parent 89ece36 commit 155def7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

driver/src/operation/bulk_write.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ where
175175
n_modified,
176176
upserted,
177177
} => {
178+
// small optimization for SERVER-113344: if the server unexpectedly returns a
179+
// success response for an errors-only bulk write, skip deserializing the individual
180+
// response, as the call to add_*_result will be a no-op
181+
if R::errors_only() {
182+
return Ok(());
183+
}
178184
let model = self.get_model(response.index)?;
179185
match model.operation_type() {
180186
OperationType::Insert => {
@@ -183,12 +189,8 @@ where
183189
result.add_insert_result(index, insert_result);
184190
}
185191
OperationType::Update => {
186-
let modified_count =
187-
n_modified.ok_or_else(|| ErrorKind::InvalidResponse {
188-
message: "nModified value not returned for update bulkWrite \
189-
operation"
190-
.into(),
191-
})?;
192+
// default to 0 as a workaround for SERVER-113026
193+
let modified_count = n_modified.unwrap_or(0);
192194
let update_result = UpdateResult {
193195
matched_count: n,
194196
modified_count,

0 commit comments

Comments
 (0)