osd: Test peering flush batches waiting for the PG history #132

Merged
vitalif merged 1 commits from koolkhel/vitastor:peering-flush-minsize-tests into master 2026-11-19 15:30:16 +03:00

View File

@@ -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<std::vector<osd_num_t>>({ { 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();