shutdownServer failed, No electable secondaries caught up

1,402 views
Skip to first unread message

xiang

unread,
Jan 1, 2017, 8:03:21 AM1/1/17
to mongodb-user
I run shutdownserver command in a primary server , and failed with:

repl1:PRIMARY> db.shutdownServer()
2017-01-01T20:53:00.788+0800 E QUERY    [thread1] Error: shutdownServer failed: {
"ok" : 0,
"errmsg" : "No electable secondaries caught up as of 2017-01-01T20:53:00.787+0800. Please use {force: true} to force node to step down.",
"code" : 50
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.shutdownServer@src/mongo/shell/db.js:302:1
@(shell):1:1

My mongodb version is 3.2.6, and this Replica Set composed of one primary, one secondary and one arbit.  The errmsg is "No electable secondaries caught up", it seems that the seciondary can't be elected as primary. But when I run rs.stepDown() the primary will be secondary, and the secondary will be primary. 
so ,why? 

Rhys Campbell

unread,
Jan 1, 2017, 11:44:35 AM1/1/17
to mongodb-user
Post the output of rs.conf()

Attila Tozser

unread,
Jan 1, 2017, 6:18:01 PM1/1/17
to mongod...@googlegroups.com
Hi, 

That is the designed behavior maybe, if the replication lag was over 10s when you issued the first command, and went under it, when you issued the second.
Check this ticket for example : https://jira.mongodb.org/browse/SERVER-18753

Most probably you have a replication lag floating on the border of 10s interval, or between the two commands it went under the 10 s treshold. You may can monitor the replication lag to prove this idea. 

As you can check here: https://docs.mongodb.com/manual/reference/method/rs.stepDown/#rs.stepDown for the stepdown command should have the same behavior. 

You can play around with the timeout parameter on the shutdown command, or use the force. 

Best,
Attila

2017-01-01 17:44 GMT+01:00 'Rhys Campbell' via mongodb-user <mongod...@googlegroups.com>:
Post the output of rs.conf()

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/ddeb188f-b56d-4735-9ecd-f47add515c00%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

xiang

unread,
Jan 2, 2017, 8:42:03 PM1/2/17
to mongodb-user
repl1:PRIMARY> rs.conf()
{
"_id" : "repl1",
"version" : 2,
"protocolVersion" : NumberLong(1),
"members" : [
{
"_id" : 1,
"host" : "XXX.XXX.XXX.209:20001",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 2,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 2,
"host" : "XXX.XXX.XXX.210:20001",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 3,
"host" : "XXX.XXX.XXX.214:20001",
"arbiterOnly" : true,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
},
"replicaSetId" : ObjectId("58049e0c37adfb653ee89e1d")
}
}



在 2017年1月2日星期一 UTC+8上午12:44:35,Rhys Campbell写道:

xiang

unread,
Jan 2, 2017, 8:46:24 PM1/2/17
to mongodb-user
repl1:PRIMARY>  db.shutdownServer()
2017-01-03T09:42:26.211+0800 E QUERY    [thread1] Error: shutdownServer failed: {
"ok" : 0,
"errmsg" : "No electable secondaries caught up as of 2017-01-03T09:42:26.210+0800. Please use {force: true} to force node to step down.",
"code" : 50
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.shutdownServer@src/mongo/shell/db.js:302:1
@(shell):1:1

repl1:PRIMARY> db.printReplicationInfo()
configured oplog size:   51200MB
log length start to end: 614885secs (170.8hrs)
oplog first event time:  Tue Dec 27 2016 06:54:33 GMT+0800 (CST)
oplog last event time:   Tue Jan 03 2017 09:42:38 GMT+0800 (CST)
now:                     Tue Jan 03 2017 09:42:38 GMT+0800 (CST)
repl1:PRIMARY> db.printSlaveReplicationInfo()
source: XXX.XXX.XXX.210:20001
syncedTo: Tue Jan 03 2017 09:42:44 GMT+0800 (CST)
1 secs (0 hrs) behind the primary 

but it seems that no lag between primary and secondary.

在 2017年1月2日星期一 UTC+8上午7:18:01,Attila Tozser写道:
Hi, 

That is the designed behavior maybe, if the replication lag was over 10s when you issued the first command, and went under it, when you issued the second.
Check this ticket for example : https://jira.mongodb.org/browse/SERVER-18753

Most probably you have a replication lag floating on the border of 10s interval, or between the two commands it went under the 10 s treshold. You may can monitor the replication lag to prove this idea. 

As you can check here: https://docs.mongodb.com/manual/reference/method/rs.stepDown/#rs.stepDown for the stepdown command should have the same behavior. 

You can play around with the timeout parameter on the shutdown command, or use the force. 

Best,
Attila
2017-01-01 17:44 GMT+01:00 'Rhys Campbell' via mongodb-user <mongod...@googlegroups.com>:
Post the output of rs.conf()

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.

To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
Reply all
Reply to author
Forward
0 new messages