[SERVER-56887] setIndexCommitQuorum command returns {ok: 1} when run against a mongos on a non-existent index build Created: 12/May/21  Updated: 29/Oct/23  Resolved: 12/Aug/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.0.0, 4.4.6
Fix Version/s: 4.4.11, 5.0.4, 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Gregory Wlodarek Assignee: Haley Connelly
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0, v4.4
Steps To Reproduce:

(function() {
"use strict";
 
const st = new ShardingTest({shards: 1, mongos: 1, rs: {nodes: 1}});
 
const mongosDB = st.s0.getDB(jsTestName());
const mongosColl = mongosDB[jsTestName()];
 
assert.commandWorked(mongosColl.insert({_id: 1}));
 
// Should not be OK.
assert.commandWorked(mongosDB.runCommand(
    {setIndexCommitQuorum: jsTestName(), indexNames: ["abcd"], commitQuorum: 1}));
 
// Mongos should fail with this error code too.
let replTest = st.rs0;
assert.commandFailedWithCode(
    replTest.getPrimary()
        .getDB(jsTestName())
        .runCommand({setIndexCommitQuorum: jsTestName(), indexNames: ["abcd"], commitQuorum: 1}),
    ErrorCodes.IndexNotFound);
 
st.stop();
}());

Sprint: Execution Team 2021-08-09, Execution Team 2021-08-23
Participants:

 Description   

I tried to run setIndexCommitQuorum against a mongos on a non-existent index build and the command returns successfully:

{
       "ok" : 1,
       "$clusterTime" : {
               "clusterTime" : Timestamp(1620827363, 2),
               "signature" : {
                       "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                       "keyId" : NumberLong(0)
               }
       },
       "operationTime" : Timestamp(1620827363, 2)
}

Running the same command against the primary mongod returns the expected result:

{
       "ok" : 0,
       "errmsg" : "Cannot find an index build on collection 'repro.repro' with the provided index names",
       "code" : 27,
       "codeName" : "IndexNotFound",
       "$gleStats" : {
               "lastOpTime" : {
                       "ts" : Timestamp(1620827362, 16),
                       "t" : NumberLong(1)
               },
               "electionId" : ObjectId("7fffffff0000000000000001")
       },
       "lastCommittedOpTime" : Timestamp(1620827363, 2),
       "$configServerState" : {
               "opTime" : {
                       "ts" : Timestamp(1620827362, 22),
                       "t" : NumberLong(-1)
               }
       },
       "$clusterTime" : {
               "clusterTime" : Timestamp(1620827363, 2),
               "signature" : {
                       "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                       "keyId" : NumberLong(0)
               }
       },
       "operationTime" : Timestamp(1620827363, 2)
}



 Comments   
Comment by Githook User [ 14/Oct/21 ]

Author:

{'name': 'Haley Connelly', 'email': 'haley.connelly@mongodb.com', 'username': 'haleyConnelly'}

Message: SERVER-56887 setIndexCommitQuorum command does not return

{ok: 1}

when run against a mongos on a non-existent index build

(cherry picked from commit d0f6a9a599a81e5563c353177a1e7c2df9c21302)
Branch: v4.4
https://github.com/mongodb/mongo/commit/5bafc36d26421b80101a45aab2ce6bf3ec30b1f5

Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 29/Sep/21 ]

Author:

{'name': 'Haley Connelly', 'email': 'haley.connelly@mongodb.com', 'username': 'haleyConnelly'}

Message: SERVER-56887 setIndexCommitQuorum command does not return

{ok: 1}

when run against a mongos on a non-existent index build

(cherry picked from commit d0f6a9a599a81e5563c353177a1e7c2df9c21302)
Branch: v5.0
https://github.com/mongodb/mongo/commit/3dc2c03b78d7d33273bd650f2269495ef747ec6d

Comment by Haley Connelly [ 12/Aug/21 ]

The outcome of this ticket:

setIndexCommitQuorum on a mongos now broadcasts only to shards that own chunks. Additionally, it reports which shards report success and which failed (if any) along with the standard {ok: <>} response.

One thing to note - suppose mongos broadcasts the command to 2 shards:
. shard0 succeeds
. shard1 throws stale config exception
. mongos internally retries sending the commands to both shard0 and shard1
. shard0 reports an error the second time since it already succeeded (pretend the index quorum was satisfied after the first round and there is no longer an active index on the shard)
. users will see shard0 failed despite the index quorum succeeding on shard0 before the internal retry since the command is not idempotent

We believe the scenario to be possible but highly unlikely

Comment by Githook User [ 12/Aug/21 ]

Author:

{'name': 'Haley Connelly', 'email': 'haley.connelly@mongodb.com', 'username': 'haleyConnelly'}

Message: SERVER-56887 setIndexCommitQuorum command does not return

{ok: 1}

when run against a mongos on a non-existent index build
Branch: master
https://github.com/mongodb/mongo/commit/d0f6a9a599a81e5563c353177a1e7c2df9c21302

Generated at Thu Feb 08 05:40:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.