diff --git a/src/osd/osd_peering.cpp b/src/osd/osd_peering.cpp index 47cbe148..2fcb8abc 100644 --- a/src/osd/osd_peering.cpp +++ b/src/osd/osd_peering.cpp @@ -21,13 +21,6 @@ void osd_t::handle_peers() { if (continue_pg_peering(p.second)) { - // Not wakeup(): it runs the next calc in the same ring loop pass, before - // any completion is read, and back-to-back calcs of large PGs starve pings - peering_yield_timer_id = tfd->set_timer(1, false, [this](int) - { - peering_yield_timer_id = -1; - ringloop->wakeup(); - }); return; } else @@ -361,10 +354,18 @@ bool osd_t::continue_pg_peering(pg_t & pg) submit_list_subop(peer_osd, pg.peering_state); } } - if (pg.peering_state->lists_done) + // continue_pg() gets here too, and a re-peer keeps the lists of the peers that stay + if (pg.peering_state->lists_done && peering_yield_timer_id < 0) { auto history_size = pg.target_history.size(); pg.calc_object_states(log_level); + // Not wakeup(): it runs the next calc in the same ring loop pass, before + // any completion is read, and back-to-back calcs of large PGs starve pings + peering_yield_timer_id = tfd->set_timer(1, false, [this](int) + { + peering_yield_timer_id = -1; + ringloop->wakeup(); + }); // Two-phase delete needs tombstone support in stores of all PG members pg.enable_tombstones = (pg.state & PG_ACTIVE) && bs->supports_tombstones(); if (pg.enable_tombstones) diff --git a/src/test/osd_test.cpp b/src/test/osd_test.cpp index f4426e76..49e93ec0 100644 --- a/src/test/osd_test.cpp +++ b/src/test/osd_test.cpp @@ -2517,6 +2517,40 @@ void test_sync_interference() printf("test_sync_interference passed\n"); } +// A re-peer keeps the lists of the peers that stay, so a PG waiting for its calc may have all +// of them at once: its calc must still wait for the yield timer, or a peer whose /osd/state +// disappears re-peers and calculates every such PG back to back +void test_peering_yields_after_repeer() +{ + printf("test_peering_yields_after_repeer\n"); + + osd_test_fixture_t f; + f.configure_replicated_pool(1, 2, 1, 2, { { 1, 2 }, { 1, 2 } }); + f.start(json11::Json::object { + { "osd_num", 1 }, + { "etcd_address", "127.0.0.1:2379" }, + { "immediate_commit", "none" }, + { "block_size", 131072 }, + { "bitmap_granularity", 4096 }, + }); + f.connect_peer(2); + f.complete_peering_empty(false); + + f.ringloop->wakeup(); + f.ringloop->loop(); + assert((f.pg(1, 1).state == PG_PEERING) != (f.pg(1, 2).state == PG_PEERING)); + pg_t & second = f.pg(1, 1).state == PG_PEERING ? f.pg(1, 1) : f.pg(1, 2); + // What on_change_osd_state_hook() does when the /osd/state of a connected peer disappears + f.repeer_pgs(2); + assert(second.state == PG_PEERING); + f.pump(); + assert(second.state == PG_ACTIVE); + f.complete_peering_empty(); + assert(f.pg(1, 1).state == PG_ACTIVE); + assert(f.pg(1, 2).state == PG_ACTIVE); + printf("test_peering_yields_after_repeer passed\n"); +} + // Completions (pings, timers, etcd lease replies) are read only at the start of a ring loop // pass, so two PG calcs must never run in one pass: back-to-back calcs of large PGs leave // the OSD deaf for seconds, and peers and etcd take it for dead @@ -5626,6 +5660,7 @@ int main(int narg, char *args[]) test_tombstone_replicated_roles(); test_tombstone_inline_misplaced(); test_tombstone_forget_counters(); + test_peering_yields_after_repeer(); test_peering_yields_between_pgs(); return 0; }