From 7b214cba9a04048d6353e1fe29be244e781ca433 Mon Sep 17 00:00:00 2001 From: Kautilya Tripathi Date: Tue, 7 Jul 2026 09:35:20 +0530 Subject: [PATCH] crimson/osd: discard stale primary backfill scan after backfill finishes do_request_primary_scan() is an async coroutine. Backfill can complete (and on_pg_clean() can destroy backfill_state) while the coroutine is suspended in scan_for_backfill_primary(), e.g. waiting on an object context load. Resuming and delivering PrimaryScanned then dereferences a null backfill_state. Discard the scan result if backfill_state is gone; the backfill has already finished successfully. Fixes: https://tracker.ceph.com/issues/77623 Signed-off-by: Kautilya Tripathi --- src/crimson/osd/pg_recovery.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/crimson/osd/pg_recovery.cc b/src/crimson/osd/pg_recovery.cc index 7b252e212cf..678464dd5c8 100644 --- a/src/crimson/osd/pg_recovery.cc +++ b/src/crimson/osd/pg_recovery.cc @@ -542,6 +542,13 @@ PGRecovery::do_request_primary_scan(hobject_t begin) local_conf()->osd_backfill_scan_min, local_conf()->osd_backfill_scan_max, pg->get_peering_state().get_backfill_targets()); + if (!backfill_state) { + // Backfill may finish (and tear down backfill_state) while this + // coroutine is suspended in scan_for_backfill_primary(). + DEBUGDPP("primary scan result discarded, backfill finished", + *pg->get_dpp()); + co_return; + } using BackfillState = crimson::osd::BackfillState; backfill_state->process_event( BackfillState::PrimaryScanned{ std::move(bi) }.intrusive_from_this()); -- 2.47.3