SERVER-113026 Adding nModified field to bulkWrite command without shard key (#44652)
GitOrigin-RevId: ffc98f8a921f429f461e8bf8860f2793adcb1679
This commit is contained in:
parent
2d1c745719
commit
89a53aa012
@ -50,6 +50,7 @@ selector:
|
||||
- jstests/sharding/deleteOne_with_id_without_shard_key_stale_config.js
|
||||
- jstests/sharding/batched_writes_with_id_without_shard_key_stale_config.js
|
||||
- jstests/sharding/batched_writes_with_id_without_shard_key_basic.js
|
||||
- jstests/sharding/updateOne_without_shard_key/updateOne_without_shard_key_basic.js
|
||||
- jstests/sharding/updateOne_without_shard_key/write_without_shard_key_single_shard_data_placement_change.js
|
||||
- jstests/sharding/timeseries/timeseries_writes_without_shard_key_single_shard_data_placement_change.js
|
||||
- jstests/sharding/retryable_update_one_by_id_chunk_migration.js
|
||||
|
||||
@ -198,6 +198,8 @@ export const BulkWriteUtils = (function () {
|
||||
response.n += bulkWriteResponse.nInserted;
|
||||
} else if (cmd.ops[0].hasOwnProperty("update")) {
|
||||
response.n += bulkWriteResponse.nMatched;
|
||||
// 'nModified' field should always exist for an update op.
|
||||
assert(bulkWriteResponse.hasOwnProperty("nModified"), bulkWriteResponse);
|
||||
response.nModified += bulkWriteResponse.nModified;
|
||||
} else if (cmd.ops[0].hasOwnProperty("delete")) {
|
||||
response.n += bulkWriteResponse.nDeleted;
|
||||
@ -311,7 +313,9 @@ export const BulkWriteUtils = (function () {
|
||||
resp["writeErrors"].push(writeError);
|
||||
} else {
|
||||
resp.n += current.n;
|
||||
if (current.hasOwnProperty("nModified")) {
|
||||
// 'nModified' field should always exist for an update op.
|
||||
if (resp.hasOwnProperty("nModified")) {
|
||||
assert(current.hasOwnProperty("nModified"), current);
|
||||
resp.nModified += current.nModified;
|
||||
}
|
||||
if (current.hasOwnProperty("upserted")) {
|
||||
|
||||
@ -424,7 +424,11 @@ void executeWriteWithoutShardKey(
|
||||
// running errors only in which case we set an empty vector.
|
||||
auto items = std::vector<mongo::BulkWriteReplyItem>{};
|
||||
if (!bulkWriteOp.getClientRequest().getErrorsOnly()) {
|
||||
items.push_back(BulkWriteReplyItem(0));
|
||||
BulkWriteReplyItem item(0);
|
||||
if (op.getType() == BulkWriteCRUDOp::OpType::kUpdate) {
|
||||
item.setNModified(0);
|
||||
}
|
||||
items.push_back(std::move(item));
|
||||
}
|
||||
bulkWriteResponse.setCursor(
|
||||
BulkWriteCommandResponseCursor(0, // cursorId
|
||||
|
||||
@ -151,6 +151,7 @@ BSONObj constructUpsertResponse(BatchedCommandResponse& writeRes,
|
||||
BulkWriteReplyItem replyItem(0);
|
||||
replyItem.setOk(1);
|
||||
replyItem.setN(writeRes.getN());
|
||||
replyItem.setNModified(0);
|
||||
replyItem.setUpserted(upsertedId);
|
||||
BulkWriteCommandReply bulkWriteReply(
|
||||
BulkWriteCommandResponseCursor(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user