summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2013-05-21 17:07:53 -0400
committerDan Pasette <dan@10gen.com>2013-06-19 19:03:13 -0400
commit3b0ac30a7b16bddde3788f35d4e16d1777fdd8a3 (patch)
tree109eef523eb97068403a66bd95cd0788f78bdd9e
parentf91d6f0a74e4410b93d6b30e2352fe589f71a5d7 (diff)
downloadmongo-3b0ac30a7b16bddde3788f35d4e16d1777fdd8a3.tar.gz
SERVER-9283 lastHeartbeatRecv flaps between invalid and valid dates during replicaset initilization
Do not overwrite lastHeartbeatRecv with 0 value everytime HeartbeatInfo gets updated.
-rw-r--r--src/mongo/db/repl/heartbeat.cpp24
-rw-r--r--src/mongo/db/repl/rs.cpp11
-rw-r--r--src/mongo/db/repl/rs.h5
-rw-r--r--src/mongo/db/repl/rs_member.h6
4 files changed, 39 insertions, 7 deletions
diff --git a/src/mongo/db/repl/heartbeat.cpp b/src/mongo/db/repl/heartbeat.cpp
index 5ba3d5f3427..f1bc18168f6 100644
--- a/src/mongo/db/repl/heartbeat.cpp
+++ b/src/mongo/db/repl/heartbeat.cpp
@@ -49,6 +49,22 @@ namespace mongo {
return jsTime() - downSince;
}
+ void HeartbeatInfo::updateFromLastPoll(const HeartbeatInfo& newInfo) {
+ hbstate = newInfo.hbstate;
+ health = newInfo.health;
+ upSince = newInfo.upSince;
+ downSince = newInfo.downSince;
+ lastHeartbeat = newInfo.lastHeartbeat;
+ lastHeartbeatMsg = newInfo.lastHeartbeatMsg;
+ // Note: lastHeartbeatRecv is updated through CmdReplSetHeartbeat::run().
+
+ syncingTo = newInfo.syncingTo;
+ opTime = newInfo.opTime;
+ skew = newInfo.skew;
+ authIssue = newInfo.authIssue;
+ ping = newInfo.ping;
+ }
+
/* { replSetHeartbeat : <setname> } */
class CmdReplSetHeartbeat : public ReplSetCommand {
public:
@@ -143,7 +159,9 @@ namespace mongo {
}
// note that we got a heartbeat from this node
- from->get_hbinfo().recvHeartbeat();
+ theReplSet->mgr->send(boost::bind(&ReplSet::msgUpdateHBRecv,
+ theReplSet, from->hbinfo().id(), time(0)));
+
return true;
}
@@ -445,10 +463,6 @@ namespace mongo {
time_t _timeout;
};
- void HeartbeatInfo::recvHeartbeat() {
- lastHeartbeatRecv = time(0);
- }
-
int ReplSetHealthPollTask::s_try_offset = 0;
void ReplSetImpl::endOldHealthTasks() {
diff --git a/src/mongo/db/repl/rs.cpp b/src/mongo/db/repl/rs.cpp
index 1c135556c6f..8646b6eb2d3 100644
--- a/src/mongo/db/repl/rs.cpp
+++ b/src/mongo/db/repl/rs.cpp
@@ -244,7 +244,16 @@ namespace mongo {
void ReplSetImpl::msgUpdateHBInfo(HeartbeatInfo h) {
for( Member *m = _members.head(); m; m=m->next() ) {
if( m->id() == h.id() ) {
- m->_hbinfo = h;
+ m->_hbinfo.updateFromLastPoll(h);
+ return;
+ }
+ }
+ }
+
+ void ReplSetImpl::msgUpdateHBRecv(unsigned id, time_t newTime) {
+ for (Member *m = _members.head(); m; m = m->next()) {
+ if (m->id() == id) {
+ m->_hbinfo.lastHeartbeatRecv = newTime;
return;
}
}
diff --git a/src/mongo/db/repl/rs.h b/src/mongo/db/repl/rs.h
index 1e7c86596c9..18576106e3c 100644
--- a/src/mongo/db/repl/rs.h
+++ b/src/mongo/db/repl/rs.h
@@ -332,6 +332,11 @@ namespace mongo {
/* todo thread */
void msgUpdateHBInfo(HeartbeatInfo);
+ /**
+ * Updates the lastHeartbeatRecv of Member with the given id.
+ */
+ void msgUpdateHBRecv(unsigned id, time_t newTime);
+
StateBox box;
OpTime lastOpTimeWritten;
diff --git a/src/mongo/db/repl/rs_member.h b/src/mongo/db/repl/rs_member.h
index 100a2013314..b59d958e584 100644
--- a/src/mongo/db/repl/rs_member.h
+++ b/src/mongo/db/repl/rs_member.h
@@ -101,7 +101,11 @@ namespace mongo {
/* true if changed in a way of interest to the repl set manager. */
bool changed(const HeartbeatInfo& old) const;
- void recvHeartbeat();
+ /**
+ * Updates this with the info received from the command result we got from
+ * the last replSetHeartbeat.
+ */
+ void updateFromLastPoll(const HeartbeatInfo& newInfo);
};
inline HeartbeatInfo::HeartbeatInfo(unsigned id) :