Project

General

Profile

Actions

Bug #81592

closed
AK AK

osd/SnapMapper: purged_snaps scrub keeps every OSD at ~100% CPU for days (iterator rescans purged history per mapping key)

Bug #81592: osd/SnapMapper: purged_snaps scrub keeps every OSD at ~100% CPU for days (iterator rescans purged history per mapping key)

Added by Ante Kuspilic about 2 months ago. Updated 22 days ago.

Status:
Backporting
Priority:
Normal
Assignee:
Category:
Performance/Resource Usage
Target version:
Due date:
% Done:

0%

Source:
Community (dev)
Backport:
umbrella, tentacle
Regression:
Yes
Severity:
2 - major
Reviewed:
ceph-qa-suite:
Component(RADOS):
OSD
Pull request ID:
Tags (freeform):
Fixed In:
v22.0.0-697-g15101d95cd
Released In:
Upkeep Timestamp:
2026-11-11T14:56:08+00:00

Description

Since Tentacle, the purged_snaps scrub pins a core at ~100% CPU for days on every OSD of a snapshot-heavy cluster. I noticed it a day after the upgrade of Reef to Tentacle 20.2.1: all CPU cores were sitting at 100% and the cluster behaved far worse performance/latency wise.

Debugging led to SnapMapper::Scrubber::run(). Up to Squid the purged-snaps scrub was a two-cursor merge-join, O(M+P): two get_omap_iterator() cursors walked the purged history and the mappings once, together. Upstream deprecated get_omap_iterator() (2024-11-18) and deleted it from main (2024-11-29) in favor of the async omap_iterate() callback API, the interface that works for both classic stores and crimson. The migration commit ("osd: switch SnapMapper to omap_iterate", 2024-11-27) rewrote Scrubber::run() and lost the merge-join: since Tentacle it reopens the purged history from its first row for every mapping key -> O(M*P), where:

M = SNA_ mapping rows
P = PSN_ purged-history rows

The old algorithm cannot be restored: the API it is written against no longer exists on main.

Attached patch works like this:
  • collect the ranges once -> sort numerically by (pool, begin), std::lower_bound per key. O(M log P), P-flat; 84x at (100k,1k), faster at every point (MemStore bench, main HEAD, same production writers on both variants).
M P stock s patched s
1000 10 0.0019 0.00083
1000 100 0.0100 0.00090
10000 100 0.103 0.0112
10000 1000 1.05 0.0120
100000 1000 10.5 0.125

Stock: ~x10 per x10 in either factor.

Unit test added in test_scrubber_run.cc.

Backport: main, tentacle, 21.x. Squid not affected (v19.2.6 still merge-join). Verified: ceph_test_snap_mapper 11/11 on both variants; memstore vstart OSD-level scenario emits the identical purged_snaps scrub starts -> scrub ok contract on both.


Files

0001-osd-SnapMapper-stop-rescanning-purged_snaps-per-mapp.patch (34.6 KB) 0001-osd-SnapMapper-stop-rescanning-purged_snaps-per-mapp.patch Fix + ceph_test_scrubber_run unit test, one commit on main 5f7e383ae6d Ante Kuspilic, 10/09/2026 04:19 PM

Related issues 2 (2 open — 0 closed)

Copied to RADOS - Backport #83057: umbrella: osd/SnapMapper: purged_snaps scrub keeps every OSD at ~100% CPU for days (iterator rescans purged history per mapping key)New

Actions
Copied to RADOS - Backport #83058: tentacle: osd/SnapMapper: purged_snaps scrub keeps every OSD at ~100% CPU for days (iterator rescans purged history per mapping key)Fix Under ReviewRonen Friedman

Actions

AK Updated by Ante Kuspilic about 2 months ago Actions #3

  • Private changed from Yes to No

NT Updated by Niccolo Tosato about 2 months ago Actions #4

Hello,

After upgrading from Ceph 19.2.4 to 20.2.2, we started seeing repeated `BLUESTORE_SLOW_OP_ALERT` warnings on many of our HDD OSDs. Our cluster has approximately 300 HDD OSDs, and the health output reports:

```
osd.XXX observed slow operation indications in BlueStore
```

I suspect this may be related to the issue described here, although I have not confirmed the root cause. On two affected OSDs on different hosts, the slow operation occurs during `purged_snaps` scrubbing.

osd.94 on ceph07:

```text
Oct 10 16:51:06 ceph07 ceph-osd13431: log_channel(cluster) log [DBG] : purged_snaps scrub starts
Oct 10 16:53:50 ceph07 ceph-osd13431: bluestore(/var/lib/ceph/osd/ceph-94) log_latency slow operation observed for omap_iterate, latency = 19.262397766s
Oct 10 16:53:50 ceph07 ceph-osd13431: log_channel(cluster) log [DBG] : purged_snaps scrub ok
```

osd.0 on ceph11:

```text
Oct 10 05:48:37 ceph11 ceph-osd23158: log_channel(cluster) log [DBG] : purged_snaps scrub starts
Oct 10 05:50:40 ceph11 ceph-osd23158: bluestore(/var/lib/ceph/osd/ceph-0) log_latency slow operation observed for omap_iterate, latency = 7.423174381s
Oct 10 05:50:40 ceph11 ceph-osd23158: log_channel(cluster) log [DBG] : purged_snaps scrub ok
```

Both scrubs completed successfully, with wall times of approximately 164 and 123 seconds respectively. No `stalled read` messages appeared in the inspected journal output.

The effective settings on osd.94 are:

```text
bluestore_log_omap_iterator_age = 5
bluestore_slow_ops_warn_lifetime = 86400
bluestore_slow_ops_warn_threshold = 1
```

My understanding is that a single qualifying event is therefore enough to retain the health warning for approximately 24 hours.

Looking at the changes to `SnapMapper::Scrubber::run()` between Squid and Tentacle, the repeated purged-history iteration described in this issue seems like a plausible explanation. However, I have not yet measured the scrub’s CPU consumption or established its impact on client latency, so I cannot say whether we are experiencing the same regression.

I am sharing these observations as additional production evidence. Could you advise whether they appear consistent with this issue and which further measurements would be useful? I would also appreciate any information about a possible Tentacle backport of PR #72544.

Thank you for investigating this.

RZ Updated by Radoslaw Zarzynski about 2 months ago Actions #5

  • Status changed from New to Fix Under Review

KS Updated by Kamoltat (Junior) Sirivadhna about 2 months ago · Edited Actions #6

  • Status changed from Fix Under Review to Pending Backport

KS Updated by Kamoltat (Junior) Sirivadhna about 2 months ago Actions #7

  • Status changed from Pending Backport to Fix Under Review

LF Updated by Laura Flores about 2 months ago Actions #8

PR needs a rework based on requested changes.

AK Updated by Ante Kuspilic about 2 months ago Actions #9

The PR has been reworked per the requested changes and force-pushed (commit b381d2164eb). Review has been re-requested.

The correctness half of the same walk is tracked in #81798 — the PR fixes both.

KS Updated by Kamoltat (Junior) Sirivadhna about 1 month ago Actions #10

waiting for ronen to review

RF Updated by Ronen Friedman about 1 month ago Actions #11

@Kamoltat (Junior) Sirivadhna - shouldn't this be backported to Umbrella?

KS Updated by Kamoltat (Junior) Sirivadhna about 1 month ago Actions #12

  • Backport set to umbrella, tentacle

KS Updated by Kamoltat (Junior) Sirivadhna about 1 month ago Actions #13

@Ronen Friedman main PR is sent to QA, Added umbrella and tentacle backport.

LF Updated by Laura Flores 28 days ago Actions #14

  • Assignee set to Ante Kuspilic

LF Updated by Laura Flores 28 days ago Actions #15

PR added to a QA batch.

UB Updated by Upkeep Bot 22 days ago Actions #16

  • Copied to Backport #83057: umbrella: osd/SnapMapper: purged_snaps scrub keeps every OSD at ~100% CPU for days (iterator rescans purged history per mapping key) added

UB Updated by Upkeep Bot 22 days ago Actions #17

  • Copied to Backport #83058: tentacle: osd/SnapMapper: purged_snaps scrub keeps every OSD at ~100% CPU for days (iterator rescans purged history per mapping key) added

UB Updated by Upkeep Bot 22 days ago Actions #18

  • Status changed from Fix Under Review to Backporting
  • Merge Commit set to 15101d95cde4f1801bacc23de55ff49f82a545c4
  • Fixed In set to v22.0.0-697-g15101d95cd
  • Upkeep Timestamp set to 2026-11-11T14:56:08+00:00
Actions

Also available in: PDF Atom