Re: Error when creating custom write concern using tags

68 views
Skip to first unread message

Rob Moore

unread,
Oct 12, 2012, 9:11:39 PM10/12/12
to mongod...@googlegroups.com

I found this confusing at first too.

The number in the getLastErrorModes is the number of _unique values_ for the tag name.  Not the number of replicas with that tag.

In your example you have 1 unique value for the tag name "dc".  That is "p".  The error is saying the write mode will never finish since there are not two unique "dc"s to replicate to.

The intent is that you can force the write across different sets of replicas.  Not that it be replicated to N of the total set. (You still have 'w' for that.)

Does that help?

Rob.


On Friday, October 12, 2012 8:35:49 PM UTC-4, CS wrote:
Hi folks,

I'm having some trouble creating a custom write concern using tags in 2.0.7 and 2.2.0, I get the following error:

"errmsg" : "exception: mode { dc: 2.0 } requires 2 tagged with dc, but only 1 with this tag were found",

However, there is more than 2 dc tags in the config:
rs_intg:PRIMARY> rs.conf()
{
        "_id" : "rs_intg",
        "version" : 9,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "mongo-test01v:27017",
                        "tags" : {
                                "dc" : "p"
                        }
                },
                {
                        "_id" : 1,
                        "host" : "mongo-test02v:27017",
                        "tags" : {
                                "dc" : "p"
                        }
                },
                {
                        "_id" : 2,
                        "host" : "mongo-test03v:27017",
                        "tags" : {
                                "dc" : "p"
                        }
                },
                {
                        "_id" : 3,
                        "host" : "mongo-test04v:27017",
                        "priority" : 0,
                        "hidden" : true,
                        "tags" : {
                                "backup" : "b"
                        }
                }
        ]
}

Trying to create the write concern:
rs_intg:PRIMARY> cfg = rs.conf()
...
rs_intg:PRIMARY> cfg.settings = { getLastErrorModes : { production : { dc: 2 } } }
{ "getLastErrorModes" : { "production" : { "dc" : 2 } } }
rs_intg:PRIMARY> rs.reconfig(cfg)
{
        "errmsg" : "exception: mode { dc: 2.0 } requires 2 tagged with dc, but only 1 with this tag were found",
        "code" : 14831,
        "ok" : 0
}

But if I set it to 1, then it works:
rs_intg:PRIMARY> cfg.settings = { getLastErrorModes : { production : { dc: 1 } } }
{ "getLastErrorModes" : { "production" : { "dc" : 1 } } }
rs_intg:PRIMARY> rs.reconfig(cfg)
{ "ok" : 1 }

The status appears to be ok:
rs_intg:PRIMARY> rs.status()
{
        "set" : "rs_intg",
        "date" : ISODate("2012-10-13T00:27:21Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "mongo-test01v:27017",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 182,
                        "optime" : {
                                "t" : 1350087984000,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2012-10-13T00:26:24Z"),
                        "lastHeartbeat" : ISODate("2012-10-13T00:27:20Z"),
                        "pingMs" : 0
                },
                {
                        "_id" : 1,
"name" : "mongo-test02v:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 182,
"optime" : {
"t" : 1350087984000,
"i" : 1
},
"optimeDate" : ISODate("2012-10-13T00:26:24Z"),
"self" : true
},
{
"_id" : 2,
"name" : "mongo-test03v:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 152,
"optime" : {
"t" : 1350087984000,
"i" : 1
},
"optimeDate" : ISODate("2012-10-13T00:26:24Z"),
"lastHeartbeat" : ISODate("2012-10-13T00:27:20Z"),
"pingMs" : 1
},
{
"_id" : 3,
"name" : "mongo-test04v:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 126,
"optime" : {
"t" : 1350087984000,
"i" : 1
},
"optimeDate" : ISODate("2012-10-13T00:26:24Z"),
"lastHeartbeat" : ISODate("2012-10-13T00:27:20Z"),
"pingMs" : 0,
"errmsg" : "syncing to: mongo-test02v:27017"
}
],
"ok" : 1
}

Any suggestions appreciated, thanks!

cs

CS

unread,
Oct 12, 2012, 11:04:14 PM10/12/12
to mongod...@googlegroups.com
Ah, yes got it, thank you! 
Reply all
Reply to author
Forward
0 new messages