[SERVER-8409] collMod doesn't work when run through a mongos on an authenticated cluster Created: 30/Jan/13  Updated: 11/Jul/16  Resolved: 28/Mar/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.2.1
Fix Version/s: 2.4.0

Type: Bug Priority: Major - P3
Reporter: James Blackburn Assignee: Spencer Brody (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

RHEL 5


Issue Links:
Depends
Duplicate
is duplicated by SERVER-9142 turning on usePowerOf2Sizes throws er... Closed
Related
Operating System: ALL
Participants:

 Description   

Attempting to switch userPowerOf2Sizes on through a mongos on a sharded collection doesn't seem to work:

mongos> use mongoose
mongos> db.runCommand({"collMod":"centaur", "usePowerOf2Sizes":true})
{
        "raw" : {
                "rs0/cn14-ib:27118,cn53-ib:27118,cn17-ib:27118" : {
                        "usePowerOf2Sizes_old" : true,
                        "errmsg" : "unknown command: $auth",
                        "ok" : 0
                },
                "rs1/cn54-ib:27118,cn55-ib:27118" : {
                        "usePowerOf2Sizes_old" : true,
                        "errmsg" : "unknown command: $auth",
                        "ok" : 0
                }
        },
        "ok" : 0,
        "errmsg" : "{ rs0/cn14-ib:27118,cn53-ib:27118,cn17-ib:27118: \"unknown command: $auth\", rs1/cn54-ib:27118,cn55-ib:27118: \"unknown command: $auth\" }"
}

It's not clear to me if the problem is the fact that the cluster is authenticated, or that it's sharded...

Note the same command works fine against a plain old un-sharded, un-auth'd mongod primary:

reggie:PRIMARY> db.runCommand({"collMod":"asdf", "usePowerOf2Sizes":true})
{ "usePowerOf2Sizes_old" : false, "ok" : 1 }



 Comments   
Comment by Spencer Brody (Inactive) [ 29/May/13 ]

UPDATE: I previously commented that in 2.2, if you ran collMod against mongos it would report failure but actually succeed. I was incorrect - though it will succeed on the primaries, the failed command will not be replicated to the secondaries.
The workaround is to do as Kenny did and simply connect directly to each primary and run the collMod command for every shard.

Comment by Spencer Brody (Inactive) [ 28/Mar/13 ]

The way it was fixed in 2.4.0, however, cannot be backported. So we'll have to do a different fix (the one I described in my first comment on this ticket - it should be pretty small and straightforward), if we want to get this in the 2.2 series. Since it's just an aesthetic problem, however, it doesn't seem too important.

Comment by Spencer Brody (Inactive) [ 28/Mar/13 ]

This was fixed automatically as part of the security work that went into 2.4.0.

Comment by Spencer Brody (Inactive) [ 27/Mar/13 ]

-Running the command on all primaries will work, but is unnecessary. Running it through mongos works, it just incorrectly reports an error message. If you query db.system.namespaces on the shards you should see that the entry for the collection in question has "flags:1", which indicates that the usePowerOf2Sizes flag has been set.-

EDIT: If you run this through mongos, the command will report failure. In this situation, the cluster will be left inconsistent as the primary will have the usePowerOf2Sizes setting set, but this will not be replicated to the secondaries.

Comment by Kenny Gorman [ 22/Mar/13 ]

running the command on all primaries did indeed work.

Comment by Kenny Gorman [ 22/Mar/13 ]

Ran into this same issue. Voting!

Comment by Spencer Brody (Inactive) [ 30/Jan/13 ]

It seems like the command still works in these cases, even though it reports an errmsg and returns ok:0. If you check the system.namespaces entry for this collection, you'll see the flags actually are updated.

Comment by Spencer Brody (Inactive) [ 30/Jan/13 ]

Was able to reproduce. Problem seems to be that the collMod command iterates through all fields in the command object and returns "unknown command" if it doesn't recognize any field in the object. Would be pretty simple to just recognize and ignore the "$auth" field. This problem will go away in 2.4 now that $auth tables are gone.

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