From 9cb0d62c7222a56e2a54dc67ec242b85cd040004 Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Sat, 11 May 2024 15:00:58 +0800 Subject: [PATCH] crimson/osd/pg: hold PGs' references to the last minute of snap trim events executions Fixes: https://tracker.ceph.com/issues/65972 Signed-off-by: Xuehan Xu (cherry picked from commit 1116c418b4fed0c8b6ab42d4f6c23cdc1afbef57) --- src/crimson/osd/pg.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index ac7e2e4e31733..02630d0b732da 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -534,20 +534,22 @@ void PG::on_active_actmap() const auto needs_pause = !snap_trimq.empty(); return trim_snap(to_trim, needs_pause); } - ).finally([this] { + ).then_interruptible([this] { logger().debug("{}: PG::on_active_actmap() finished trimming", *this); peering_state.state_clear(PG_STATE_SNAPTRIM); peering_state.state_clear(PG_STATE_SNAPTRIM_ERROR); - publish_stats_to_osd(); + return seastar::now(); }); }, [this](std::exception_ptr eptr) { logger().debug("{}: snap trimming interrupted", *this); - peering_state.state_clear(PG_STATE_SNAPTRIM); - }, pg_ref); + ceph_assert(!peering_state.state_test(PG_STATE_SNAPTRIM)); + }, pg_ref).finally([pg_ref, this] { + publish_stats_to_osd(); + }); } else { logger().debug("{}: pg not clean, skipping snap trim"); - assert(!peering_state.state_test(PG_STATE_SNAPTRIM)); + ceph_assert(!peering_state.state_test(PG_STATE_SNAPTRIM)); } } -- 2.39.5