|
|
|
|
@@ -4855,6 +4855,110 @@ void test_peering_flush_waiting_batch_repeer()
|
|
|
|
|
printf("test_peering_flush_waiting_batch_repeer passed\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// An EC 2+2 PG peers with OSDs 1 and 2 only, at epoch 1. With auto_scrub, its state report carries the history
|
|
|
|
|
// for next_scrub, and etcd is slow to take it. Before it lands, OSDs 3 and 4 come back with version 2 of object A,
|
|
|
|
|
// unstable, and the PG peers again: its flush stabilizes version 2 on them, so they go into the history, and the
|
|
|
|
|
// flush waits for that history. The scrub report must not release it. Then OSD 3 stabilizes its part and is lost,
|
|
|
|
|
// and OSD 4 isn't stabilized: the PG must not activate without OSD 3 and roll version 2 back on OSD 4, leaving a
|
|
|
|
|
// lone stable part on OSD 3
|
|
|
|
|
void test_peering_flush_same_epoch_repeer()
|
|
|
|
|
{
|
|
|
|
|
printf("test_peering_flush_same_epoch_repeer\n");
|
|
|
|
|
|
|
|
|
|
inode_t ino = INODE_WITH_POOL(1, 1);
|
|
|
|
|
ec_scheme_t ec = { 2, 2, 2 };
|
|
|
|
|
std::map<osd_num_t, ec_part_t> parts = { { 1, { 1, 0 } }, { 2, { 1, 0 } }, { 3, { 1, 2 } }, { 4, { 1, 2 } } };
|
|
|
|
|
osd_test_fixture_t f;
|
|
|
|
|
f.configure_ec_pool(ec.data, ec.parity, 1, ec.pg_minsize);
|
|
|
|
|
f.start(json11::Json::object {
|
|
|
|
|
{ "osd_num", 1 }, { "etcd_address", "127.0.0.1:2379" }, { "immediate_commit", "all" },
|
|
|
|
|
{ "block_size", 131072 }, { "bitmap_granularity", 4096 }, { "auto_scrub", true },
|
|
|
|
|
});
|
|
|
|
|
auto & pg = f.pg(1, 1);
|
|
|
|
|
auto list = [&](osd_num_t osd)
|
|
|
|
|
{
|
|
|
|
|
std::vector<obj_ver_id> l;
|
|
|
|
|
object_id oid = { .inode = ino, .stripe = osd-1 };
|
|
|
|
|
if (parts[osd].stable)
|
|
|
|
|
l.push_back({ oid, parts[osd].stable });
|
|
|
|
|
if (parts[osd].unstable)
|
|
|
|
|
l.push_back({ oid, parts[osd].unstable });
|
|
|
|
|
return l;
|
|
|
|
|
};
|
|
|
|
|
std::vector<osd_num_t> connected;
|
|
|
|
|
auto answer_lists = [&]()
|
|
|
|
|
{
|
|
|
|
|
bool any = true;
|
|
|
|
|
while (any)
|
|
|
|
|
{
|
|
|
|
|
any = false;
|
|
|
|
|
for (auto *op: f.bs->queued)
|
|
|
|
|
any = any || op->opcode == BS_OP_LIST;
|
|
|
|
|
if (any)
|
|
|
|
|
f.reply_local_list(list(1), 1);
|
|
|
|
|
for (auto p: connected)
|
|
|
|
|
{
|
|
|
|
|
if (f.peer_has_sent_op(p, OSD_OP_SEC_LIST))
|
|
|
|
|
{
|
|
|
|
|
f.reply_peer_list(p, list(p), 1);
|
|
|
|
|
any = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
f.pump();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
auto etcd_sets = [&]()
|
|
|
|
|
{
|
|
|
|
|
auto h = etcd_pg_history(f);
|
|
|
|
|
return h["osd_sets"].dump() + " epoch " + h["epoch"].dump();
|
|
|
|
|
};
|
|
|
|
|
f.connect_peer(2);
|
|
|
|
|
connected = { 2 };
|
|
|
|
|
f.st_cli->pause();
|
|
|
|
|
answer_lists();
|
|
|
|
|
printf(" peered with OSDs 1, 2: state=0x%x epoch %ju, reported %ju, reporting %ju\n",
|
|
|
|
|
pg.state, pg.epoch, pg.reported_epoch, pg.reporting_epoch);
|
|
|
|
|
assert((pg.state & PG_ACTIVE) && !pg.flush_batch);
|
|
|
|
|
assert(pg.epoch == 1 && pg.reported_epoch == 0);
|
|
|
|
|
|
|
|
|
|
f.connect_peer(3);
|
|
|
|
|
f.connect_peer(4);
|
|
|
|
|
connected = { 2, 3, 4 };
|
|
|
|
|
answer_lists();
|
|
|
|
|
printf(" peered with OSDs 1-4: state=0x%x epoch %ju, reported %ju, reporting %ju, flush batch %s\n",
|
|
|
|
|
pg.state, pg.epoch, pg.reported_epoch, pg.reporting_epoch, pg.flush_batch ? "parked" : "none");
|
|
|
|
|
assert(pg.flush_batch && !pg.flush_batch->flush_ops && pg.epoch == 1 && pg.reporting_epoch == 1);
|
|
|
|
|
assert(std::count(pg.target_history.begin(), pg.target_history.end(), std::vector<osd_num_t>({ 3, 4 })));
|
|
|
|
|
|
|
|
|
|
f.st_cli->resume();
|
|
|
|
|
f.pump();
|
|
|
|
|
bool early = f.peer_has_sent_op(3, OSD_OP_SEC_STABILIZE);
|
|
|
|
|
printf(" first report landed: etcd history %s, stabilize sent: %s\n", etcd_sets().c_str(), early ? "yes" : "no");
|
|
|
|
|
// The landed history differs from the PG's, so the PG restarts and peers again before its epoch is reported
|
|
|
|
|
for (int i = 0; i < 5 && !early && !f.peer_has_sent_op(3, OSD_OP_SEC_STABILIZE); i++)
|
|
|
|
|
{
|
|
|
|
|
answer_lists();
|
|
|
|
|
// A real watch advances this revision with every event, the mock doesn't; the history put compares against it
|
|
|
|
|
f.st_cli->etcd_watch_revision_pg = f.etcd_store.mod_revision;
|
|
|
|
|
f.tfd->tick((timespec){ .tv_sec = 0, .tv_nsec = 500000000 });
|
|
|
|
|
f.pump();
|
|
|
|
|
}
|
|
|
|
|
printf(" then: etcd history %s, stabilize sent to OSDs 3, 4: %s, %s\n", etcd_sets().c_str(),
|
|
|
|
|
f.peer_has_sent_op(3, OSD_OP_SEC_STABILIZE) ? "yes" : "no", f.peer_has_sent_op(4, OSD_OP_SEC_STABILIZE) ? "yes" : "no");
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
assert(f.peer_has_sent_op(3, OSD_OP_SEC_STABILIZE) && f.peer_has_sent_op(4, OSD_OP_SEC_STABILIZE));
|
|
|
|
|
|
|
|
|
|
parts[3] = { 2, 0 };
|
|
|
|
|
json11::Json history = etcd_pg_history(f);
|
|
|
|
|
bool active_without = peer_ec_all(ec, parts, 1, { 2, 4 }, false, history).active;
|
|
|
|
|
auto r = peer_ec_all(ec, parts, 1, { 2, 3, 4 }, false, history);
|
|
|
|
|
printf(" PG active without OSD 3: %s, object complete: %s\n", active_without ? "yes" : "no", r.incomplete ? "no" : "yes");
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
assert(!early && !active_without && r.active && !r.incomplete);
|
|
|
|
|
|
|
|
|
|
printf("test_peering_flush_same_epoch_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()
|
|
|
|
|
@@ -5738,6 +5842,7 @@ int main(int narg, char *args[])
|
|
|
|
|
test_peering_flush_misplaced_primary_lost(true);
|
|
|
|
|
test_peering_flush_misplaced_primary_lost(false);
|
|
|
|
|
test_peering_flush_waiting_batch_repeer();
|
|
|
|
|
test_peering_flush_same_epoch_repeer();
|
|
|
|
|
test_peering_flush_replicated_history();
|
|
|
|
|
test_delete_waits_for_stabilize_snapshot();
|
|
|
|
|
test_delete_waits_only_for_covered_objects();
|
|
|
|
|
|