From 689cf03f5515bb116ddf3966ef57550baf97eee9 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 17 Aug 2017 19:01:40 +0800 Subject: [PATCH] mon/OSDMonitor: do not send_pg_creates with stale info we reset the "creating_pgs" with the newly accepted paxos proposal, but the creating_pgs_by_osd_epoch is out-of-sync with the new creating_pgs. so we are at risk of using stale creating_pgs_by_osd_epoch along with the new creating_pgs.pgs. to avoid this racing, we need to check the creating_pgs_epoch before sending pg-creates using creating_pgs_by_osd_epoch. Fixes: http://tracker.ceph.com/issues/20785 Signed-off-by: Kefu Chai --- src/mon/OSDMonitor.cc | 7 +++++++ src/osd/OSDMapMapping.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 164899aed2e6d..64af202e685a6 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3261,6 +3261,13 @@ epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) cons dout(30) << __func__ << " osd." << osd << " next=" << next << " " << creating_pgs_by_osd_epoch << dendl; std::lock_guard l(creating_pgs_lock); + if (creating_pgs_epoch == 0 || + creating_pgs_epoch < mapping.get_epoch()) { + dout(20) << __func__ + << " not using stale creating_pgs@" << creating_pgs_epoch << dendl; + // the subscribers will be updated when the mapping is completed anyway + return next; + } auto creating_pgs_by_epoch = creating_pgs_by_osd_epoch.find(osd); if (creating_pgs_by_epoch == creating_pgs_by_osd_epoch.end()) return next; diff --git a/src/osd/OSDMapMapping.h b/src/osd/OSDMapMapping.h index 81996641ec059..f2affdc7fcef9 100644 --- a/src/osd/OSDMapMapping.h +++ b/src/osd/OSDMapMapping.h @@ -243,7 +243,7 @@ private: mempool::osdmap_mapping::vector< mempool::osdmap_mapping::vector> acting_rmap; // osd -> pg //unused: mempool::osdmap_mapping::vector> up_rmap; // osd -> pg - epoch_t epoch; + epoch_t epoch = 0; uint64_t num_pgs = 0; void _init_mappings(const OSDMap& osdmap); -- 2.39.5