[SERVER-15863] mongos incorrectly increments command counter when receiving write command Created: 29/Oct/14  Updated: 06/Dec/22  Resolved: 05/Nov/21

Status: Closed
Project: Core Server
Component/s: Diagnostics, Sharding
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Won't Do Votes: 0
Labels: lamont-triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Sharding
Operating System: ALL
Participants:

 Description   

When mongos receives an insert command command, it will increment the command opcounter as well as the insert opcounter. This is incorrect. The correct behavior is to only increment the insert opcounter. mongod exhibits the correct behavior.

Affects master and v2.6.

To reproduce:

var st = new ShardingTest({shards: 1});
var coll = st.getDB("test").getCollection("foo");
var ret = coll.getDB().adminCommand("serverStatus");
assert.commandWorked(ret);
var commandCounters = ret.opcounters.command;
var insertCounters = ret.opcounters.insert;
assert.commandWorked(coll.runCommand("insert", {documents: [{}]}));
ret = coll.getDB().adminCommand("serverStatus");
assert.commandWorked(ret);
assert.eq(ret.opcounters.insert, insertCounters + 1); // "insert" command counts as 1 insert
assert.eq(ret.opcounters.command, commandCounters + 1); // "serverStatus" command counts as 1 command
st.stop();

The above script fails on line 11, as the command opcounter is incorrectly incremented twice.


Generated at Thu Feb 08 03:39:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.