From c9a2146b373e255f03134b2bc8bac183e253dafd Mon Sep 17 00:00:00 2001 From: Yury Luneff Date: Thu, 19 Nov 2026 14:00:26 +0300 Subject: [PATCH] osd: Test peering flush batches waiting for the PG history A peering flush that stabilizes the target version of an object waits until the OSDs holding that version are reported in the PG history. Test that such a waiting batch is dropped without sending anything when the PG repeers before the report lands, and that the PG then peers again. Also test that the holders go into the history for a replicated pool, before the flush is sent. --- src/test/osd_test.cpp | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/test/osd_test.cpp b/src/test/osd_test.cpp index 1df6133a..773bc218 100644 --- a/src/test/osd_test.cpp +++ b/src/test/osd_test.cpp @@ -3532,6 +3532,79 @@ void test_peering_flush_misplaced_primary_lost(bool on_osd2) printf("test_peering_flush_misplaced_primary_lost[v2 on OSDs 1,%s3] passed\n", on_osd2 ? "2," : ""); } +// Version 2 of object A is unstable on OSDs 1 and 2 of an EC 2+1 PG, so the peering flush batch waits until +// the history with its holders is reported. OSD 3 drops out before the report lands: the batch must be +// dropped without sending anything, and the PG must peer again +void test_peering_flush_waiting_batch_repeer() +{ + printf("test_peering_flush_waiting_batch_repeer\n"); + + inode_t ino = INODE_WITH_POOL(1, 1); + osd_test_fixture_t f; + start_ec_all(f, { 2, 1, 2 }, 1, json11::Json()); + f.connect_peer(2); + f.connect_peer(3); + auto & pg = f.pg(1, 1); + assert(pg.state == PG_PEERING); + f.st_cli->pause(); + f.reply_peer_list(2, { { { ino, 1 }, 1 }, { { ino, 1 }, 2 } }, 1); + f.reply_peer_list(3, { { { ino, 2 }, 1 } }, 1); + f.reply_local_list({ { { ino, 0 }, 1 }, { { ino, 0 }, 2 } }, 1); + f.pump(); + assert(pg.state == (PG_ACTIVE|PG_HAS_DEGRADED|PG_HAS_UNCLEAN)); + assert(pg.flush_batch && !pg.flush_batch->flush_ops); + assert(pg.target_history == std::vector>({ { 1, 2 } })); + assert(f.st_cli->queue.size() == 1); + + f.repeer_pgs(3); + assert((pg.state & (PG_ACTIVE|PG_REPEERING)) == PG_REPEERING && pg.flush_batch); + f.st_cli->resume(); + f.pump(); + assert(has_history_set(etcd_pg_history(f), json11::Json::array { 1, 2 })); + assert(pg.state == PG_PEERING && !pg.flush_batch); + assert(!f.bs->take(BS_OP_STABLE, false) && !f.bs->take(BS_OP_ROLLBACK, false)); + for (osd_num_t p: { 2, 3 }) + assert(!f.peer_has_sent_op(p, OSD_OP_SEC_STABILIZE) && !f.peer_has_sent_op(p, OSD_OP_SEC_ROLLBACK)); + + f.complete_peering_empty(); + + printf("test_peering_flush_waiting_batch_repeer passed\n"); +} + +// Version 2 of object A is stable on OSD 1 and unstable on OSD 2 of a replicated PG. The peering flush +// stabilizes it on OSD 2, so OSDs 1 and 2 must be in the history before the flush is sent, like in EC +void test_peering_flush_replicated_history() +{ + printf("test_peering_flush_replicated_history\n"); + + inode_t ino = INODE_WITH_POOL(1, 1); + osd_test_fixture_t f; + f.configure_replicated_pool(1, 2, 1, 1, { { 1, 2 } }); + f.start(json11::Json::object { + { "osd_num", 1 }, + { "etcd_address", "127.0.0.1:2379" }, + { "immediate_commit", "all" }, + { "block_size", 131072 }, + { "bitmap_granularity", 4096 }, + }); + f.connect_peer(2); + f.reply_local_list({ { { ino, 0 }, 2 } }, 1); + f.reply_peer_list(2, { { { ino, 0 }, 1 }, { { ino, 0 }, 2 } }, 1); + f.pump(); + auto & pg = f.pg(1, 1); + assert(pg.state == (PG_ACTIVE|PG_HAS_UNCLEAN)); + auto *op = f.peer_take(2, OSD_OP_SEC_STABILIZE); + assert(op->req.sec_stab.len == sizeof(obj_ver_id)); + assert(((obj_ver_id*)op->iov.buf[0].iov_base)->version == 2); + assert(has_history_set(etcd_pg_history(f), json11::Json::array { 1, 2 })); + + f.peer_complete(op, 0); + f.pump(); + assert(pg.state == PG_ACTIVE); + + printf("test_peering_flush_replicated_history passed\n"); +} + // The same for a client write to a degraded PG of pg_minsize OSDs: OSD 1 writes version 2 of object A to them // all, stabilizes its own part and loses its peers before the others stabilize theirs. The degraded OSD set is // in the PG history before the write @@ -4127,6 +4200,8 @@ int main(int narg, char *args[]) test_peering_flush_degraded_primary_lost({ 3, 2, 4 }, 4, true); test_peering_flush_misplaced_primary_lost(true); test_peering_flush_misplaced_primary_lost(false); + test_peering_flush_waiting_batch_repeer(); + test_peering_flush_replicated_history(); test_delete_waits_for_stabilize_snapshot(); test_delete_waits_only_for_covered_objects(); test_replicated_add_object_to_set_degraded(); -- 2.47.3