From: Sage Weil Date: Fri, 26 Oct 2018 15:39:28 +0000 (-0500) Subject: osd: take heartbeat_lock before checking for session X-Git-Tag: v13.2.3~17^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8bb61f7e05a67d7e3c88ab7ba6a20ac242b057ba;p=ceph.git osd: take heartbeat_lock before checking for session When we open a connection, there is a short window before we attach the session. If a fault happens quickly, we won't get the reset, and will persistently fail to send osd pings. Move the lock up to avoid this. Note that we should rarely really see connections without sessions here anyway (except when this specific race happens), so this should have no negative impact (by taking the lock when we weren't before). Fixes: http://tracker.ceph.com/issues/36602 Signed-off-by: Sage Weil (cherry picked from commit 51d8e2457d73c709bfa4f706793696b3ce704ff9) Conflicts: - src/osd/OSD.cc - use Mutex::Locker instead of std::lock_guard (latter is a C++17ism) --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 5ff1d6c58e18..265224775a18 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4756,9 +4756,9 @@ void OSD::heartbeat() bool OSD::heartbeat_reset(Connection *con) { + Mutex::Locker l(heartbeat_lock); auto s = con->get_priv(); if (s) { - heartbeat_lock.Lock(); if (is_stopping()) { heartbeat_lock.Unlock(); return true; @@ -4794,7 +4794,6 @@ bool OSD::heartbeat_reset(Connection *con) } else { dout(10) << "heartbeat_reset closing (old) failed hb con " << con << dendl; } - heartbeat_lock.Unlock(); } return true; }