summaryrefslogtreecommitdiff
path: root/db/repl
diff options
context:
space:
mode:
Diffstat (limited to 'db/repl')
-rw-r--r--db/repl/manager.cpp10
-rw-r--r--db/repl/rs.cpp6
2 files changed, 9 insertions, 7 deletions
diff --git a/db/repl/manager.cpp b/db/repl/manager.cpp
index c91adc3..fb9b6cb 100644
--- a/db/repl/manager.cpp
+++ b/db/repl/manager.cpp
@@ -98,8 +98,14 @@ namespace mongo {
const Member *primary = rs->box.getPrimary();
if (primary && highestPriority &&
- highestPriority->config().priority > primary->config().priority) {
- log() << "stepping down " << primary->fullName() << endl;
+ highestPriority->config().priority > primary->config().priority &&
+ // if we're stepping down to allow another member to become primary, we
+ // better have another member (otherOp), and it should be up-to-date
+ otherOp != 0 && highestPriority->hbinfo().opTime.getSecs() >= otherOp - 10) {
+ log() << "stepping down " << primary->fullName() << " (priority " <<
+ primary->config().priority << "), " << highestPriority->fullName() <<
+ " is priority " << highestPriority->config().priority << " and " <<
+ (otherOp - highestPriority->hbinfo().opTime.getSecs()) << " seconds behind" << endl;
if (primary->h().isSelf()) {
// replSetStepDown tries to acquire the same lock
diff --git a/db/repl/rs.cpp b/db/repl/rs.cpp
index 23abc24..9181fe9 100644
--- a/db/repl/rs.cpp
+++ b/db/repl/rs.cpp
@@ -119,8 +119,6 @@ namespace mongo {
return max;
}
- const bool closeOnRelinquish = true;
-
void ReplSetImpl::relinquish() {
LOG(2) << "replSet attempting to relinquish" << endl;
if( box.getState().primary() ) {
@@ -129,9 +127,7 @@ namespace mongo {
log() << "replSet relinquishing primary state" << rsLog;
changeState(MemberState::RS_SECONDARY);
- }
-
- if( closeOnRelinquish ) {
+
/* close sockets that were talking to us so they don't blithly send many writes that will fail
with "not master" (of course client could check result code, but in case they are not)
*/