mirror of
https://github.com/ceph/ceph
synced 2024-12-14 23:46:28 +00:00
mon: detect and warn on clock synchronization problems;
change MMonPaxos::lease_expire to lease_timestamp
This commit is contained in:
parent
bee74a1e4c
commit
9b4d25b9b1
@ -51,7 +51,7 @@ class MMonPaxos : public Message {
|
||||
version_t pn_from; // i promise to accept after
|
||||
version_t pn; // with with proposal
|
||||
version_t uncommitted_pn; // previous pn, if we are a LAST with an uncommitted value
|
||||
utime_t lease_expire;
|
||||
utime_t lease_timestamp;
|
||||
|
||||
version_t latest_version;
|
||||
bufferlist latest_value;
|
||||
@ -92,7 +92,7 @@ public:
|
||||
::encode(pn_from, payload);
|
||||
::encode(pn, payload);
|
||||
::encode(uncommitted_pn, payload);
|
||||
::encode(lease_expire, payload);
|
||||
::encode(lease_timestamp, payload);
|
||||
::encode(latest_version, payload);
|
||||
::encode(latest_value, payload);
|
||||
::encode(values, payload);
|
||||
@ -107,7 +107,7 @@ public:
|
||||
::decode(pn_from, p);
|
||||
::decode(pn, p);
|
||||
::decode(uncommitted_pn, p);
|
||||
::decode(lease_expire, p);
|
||||
::decode(lease_timestamp, p);
|
||||
::decode(latest_version, p);
|
||||
::decode(latest_value, p);
|
||||
::decode(values, p);
|
||||
|
@ -536,7 +536,7 @@ void Paxos::extend_lease()
|
||||
if (*p == whoami) continue;
|
||||
MMonPaxos *lease = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_LEASE, machine_id);
|
||||
lease->last_committed = last_committed;
|
||||
lease->lease_expire = lease_expire;
|
||||
lease->lease_timestamp = lease_expire;
|
||||
lease->first_committed = first_committed;
|
||||
mon->messenger->send_message(lease, mon->monmap->get_inst(*p));
|
||||
}
|
||||
@ -569,8 +569,15 @@ void Paxos::handle_lease(MMonPaxos *lease)
|
||||
}
|
||||
|
||||
// extend lease
|
||||
if (lease_expire < lease->lease_expire)
|
||||
lease_expire = lease->lease_expire;
|
||||
if (lease_expire < lease->lease_timestamp) {
|
||||
lease_expire = lease->lease_timestamp;
|
||||
if (g_clock.now() > lease_expire) {
|
||||
dout(0) << "lease_expire " << lease_expire
|
||||
<< " is in the past (current time " << g_clock.now()
|
||||
<< "). Clocks not synchronized or connection is very laggy"
|
||||
<< dendl;
|
||||
}
|
||||
}
|
||||
|
||||
state = STATE_ACTIVE;
|
||||
|
||||
@ -581,7 +588,7 @@ void Paxos::handle_lease(MMonPaxos *lease)
|
||||
MMonPaxos *ack = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_LEASE_ACK, machine_id);
|
||||
ack->last_committed = last_committed;
|
||||
ack->first_committed = first_committed;
|
||||
ack->lease_expire = lease_expire;
|
||||
ack->lease_timestamp = g_clock.now();
|
||||
mon->messenger->send_message(ack, lease->get_source_inst());
|
||||
|
||||
// (re)set timeout event.
|
||||
@ -627,6 +634,15 @@ void Paxos::handle_lease_ack(MMonPaxos *ack)
|
||||
dout(10) << "handle_lease_ack from " << ack->get_source()
|
||||
<< " dup (lagging!), ignoring" << dendl;
|
||||
}
|
||||
if (ack->lease_timestamp > g_clock.now())
|
||||
dout(0) << "lease_ack from follower mon" << from
|
||||
<< " was sent from future time " << ack->lease_timestamp
|
||||
<< "! Clocks not synchronized." << dendl;
|
||||
if (ack->lease_timestamp < (lease_expire - g_conf.mon_lease))
|
||||
dout(0) << "lease_ack from follower sent at time("
|
||||
<< ack->lease_timestamp << "), before lease extend was sent ("
|
||||
<< lease_expire - g_conf.mon_lease
|
||||
<< ")! Clocks not synchronized." << dendl;
|
||||
|
||||
ack->put();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user