Skip to content

tentacle: osd/SnapMapper: stop rescanning purged_snaps per mapping key - #74456

Open
Antek74 wants to merge 1 commit into
ceph:tentaclefrom
Antek74:wip-83058-tentacle
Open

Antek74 wants to merge 1 commit into
ceph:tentaclefrom
Antek74:wip-83058-tentacle

Conversation

@Antek74

@Antek74 Antek74 commented Nov 28, 2026

Copy link
Copy Markdown

Fixes: https://tracker.ceph.com/issues/83058
Original tracker: https://tracker.ceph.com/issues/81592
Original tracker: https://tracker.ceph.com/issues/81798
Backport of #72544

Depends on #73806 (same function; now merged).

Merged main commit, with two documented differences (also in the commit message):

  • The three removed assertions are ceph_assert() on main and assert() on tentacle. The cherry-pick conflicted on those lines; resolved by removing them, as upstream did.
  • Test-only: main's in-memory-only MemStore mode is absent on tentacle; the fixture uses a temporary directory.

Validation on base 34b5c66: full test build passes (1308/1308); unittest_scrubber_run 19/19; ceph_test_snap_mapper 11/11; ctest 269/273, the 4 failures are known local/environment issues unrelated to SnapMapper; OSD-level vstart check on base and patched: 3/3 OSDs purged_snaps scrub starts -> ok, no strays.

Scrubber::run() opened a fresh omap_iterate over purged_snaps, from its
start, for every mapping key: O(M*P).  On snapshot-heavy OSDs this
pinned a core for days.

Collect the purged_snaps rows once up front, sort them numerically by
(pool, begin), merge overlapping and adjacent same-pool rows into
disjoint ranges, and binary-search them per mapping key: O(M log P).

The numeric sort also fixes missed strays: with pools ordered as
decimal strings, the old walk could stop at a pool-20 row and never
reach pool 3.

The on-disk key order is not numeric in the pool (decimal string), and
rows of one pool may overlap or touch (record_purged_snaps() merges a
new interval only with rows already on disk, so intervals carried in
one call do not see each other), so the merged ranges stay sorted by
(pool, begin) and disjoint: one upper_bound per mapping key, and the
last row that starts at or before the snap is the only one that can
cover it.

Adds unittest_scrubber_run, a unit test for Scrubber::run(): it
builds a SnapMapper over a MemStore and fills it through the same
writer methods ceph-osd uses (record_purged_snaps(), add_oid()),
then checks every stray the scrub reports.

Fixes: https://tracker.ceph.com/issues/81592
Fixes: https://tracker.ceph.com/issues/81798
Signed-off-by: Ante Kuspilic <[email protected]>

Backport note:
- Main's MemStore supports an in-memory-only mode for the empty path
  (2e8eee3, PR ceph#71931); tentacle does not. The test fixture uses
  a temporary directory instead, as the original draft did. This is
  test-only; no production MemStore change.

(cherry picked from commit 43ce7a9)

Conflicts:
	src/osd/SnapMapper.cc
	- The original commit removes three assertions. On main they are
	  ceph_assert(); on tentacle they are assert(). This is a genuine
	  conflict. The resolution removes them, as upstream did.
@Antek74
Antek74 requested a review from a team as a code owner November 28, 2026 12:35
@github-actions

Copy link
Copy Markdown

Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR ci-approved to allow Jenkins CI jobs to run.

github-actions[bot]

This comment was marked as outdated.

@Antek74

Antek74 commented Dec 2, 2026

Copy link
Copy Markdown
Author

/audit retest

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

🔄 Audit Retest Triggered by @Antek74.

View workflow run

@github-actions github-actions Bot removed the releng-audit-fail Release engineering: failed backport verification audit. label Dec 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ceph Release Engineering Audit Report

Commit Parity Visualizer

BACKPORT PR #74456 SOURCE PR SOURCE STATUS
4e52171 osd/SnapMapper: stop rescanning purged_snaps per mapping key PR #72544 43ce7a9 osd/SnapMapper: stop rescanning purged_snaps per mapping key

Automated Backport Parity Review - Cherry-Pick Conflicts / Deviations

⚠️ WARNING: Cherry-pick conflicts or deviations were found that require component lead review.

A conflict or deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.

This does not necessarily indicate an issue but a maintainer should review.

**Click to expand conflict summaries.**

Deviation in Backport 4e52171 (cherry-pick of 43ce7a9)

Affected File(s)

Range Diff

Click to expand
--- Original (43ce7a9a)
+++ Backport (4e52171a)
@@ -28,3 +28,17 @@
 Fixes: https://tracker.ceph.com/issues/81592
 Fixes: https://tracker.ceph.com/issues/81798
 Signed-off-by: Ante Kuspilic <[email protected]>
+
+Backport note:
+- Main's MemStore supports an in-memory-only mode for the empty path
+  (2e8eee3bb50, PR #71931); tentacle does not. The test fixture uses
+  a temporary directory instead, as the original draft did. This is
+  test-only; no production MemStore change.
+
+(cherry picked from commit 43ce7a9acc0b9c872614a55c26baf43da268063b)
+
+Conflicts:
+	src/osd/SnapMapper.cc
+	- The original commit removes three assertions. On main they are
+	  ceph_assert(); on tentacle they are assert(). This is a genuine
+	  conflict. The resolution removes them, as upstream did.

================================================================================
RANGE DIFF
================================================================================

1:  43ce7a9acc0 ! 1:  4e52171a781 osd/SnapMapper: stop rescanning purged_snaps per mapping key
    @@ Commit message
         Fixes: https://tracker.ceph.com/issues/81798
         Signed-off-by: Ante Kuspilic <[email protected]>
     
    +    Backport note:
    +    - Main's MemStore supports an in-memory-only mode for the empty path
    +      (2e8eee3bb50, PR #71931); tentacle does not. The test fixture uses
    +      a temporary directory instead, as the original draft did. This is
    +      test-only; no production MemStore change.
    +
    +    (cherry picked from commit 43ce7a9acc0b9c872614a55c26baf43da268063b)
    +
    +    Conflicts:
    +            src/osd/SnapMapper.cc
    +            - The original commit removes three assertions. On main they are
    +              ceph_assert(); on tentacle they are assert(). This is a genuine
    +              conflict. The resolution removes them, as upstream did.
    +
      ## src/osd/SnapMapper.cc ##
     @@ src/osd/SnapMapper.cc: bool SnapMapper::Scrubber::_parse_m(
        return true;
    @@ src/osd/SnapMapper.cc: bool SnapMapper::Scrubber::_parse_m(
     +                      __func__, mapping.hoid, mapping.snap)
                       << dendl;
            } else {
    --        ceph_assert(mapping.snap >= begin);
    --        ceph_assert(mapping.snap < end);
    --        ceph_assert(mapping.hoid.pool == pool);
    +-        assert(mapping.snap >= begin);
    +-        assert(mapping.snap < end);
    +-        assert(mapping.hoid.pool == pool);
              // invalid
              dout(10) << fmt::format(
     -                      "{} stray {} snap {} in pool {} shard {} purged_snaps[{}, {})",
    @@ src/test/test_scrubber_run.cc (new)
     +// the collector against keys it must not read.
     +
     +#include <algorithm>
    ++#include <cstdlib>
    ++#include <filesystem>
     +#include <map>
    ++#include <system_error>
     +#include <tuple>
     +#include <vector>
     +
    @@ src/test/test_scrubber_run.cc (new)
     +  // mapping_drv without colliding
     +  std::map<std::pair<int64_t, int>, std::unique_ptr<SnapMapper>> mappers;
     +  bool mounted = false;
    ++  // Backport adaptation: main's MemStore supports an in-memory-only mode
    ++  // for the empty path (commit 2e8eee3bb50); tentacle does not, so the
    ++  // fixture uses a real temporary directory like the original test draft.
    ++  std::string path;
     +  CephContext *cct = g_ceph_context;
     +
     +  void SetUp() override {
    -+    store = ObjectStore::create(cct, "memstore", "");
    ++    char pathbuf[] = "/tmp/scrubber-run-test-XXXXXX";
    ++    char *d = mkdtemp(pathbuf);
    ++    ASSERT_NE(nullptr, d);
    ++    path = d;
    ++
    ++    store = ObjectStore::create(cct, "memstore", path);
     +    ASSERT_TRUE(store);
     +    ASSERT_EQ(0, store->mkfs());
     +    ASSERT_EQ(0, store->mount());
    @@ src/test/test_scrubber_run.cc (new)
     +    mapping_drv.reset();
     +    purged_drv.reset();
     +    store.reset();
    ++    std::error_code ec;
    ++    std::filesystem::remove_all(path, ec);
     +  }
     +
     +  SnapMapper &get_mapper(int64_t pool,

How to proceed:

  • Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git Conflicts: block intact) and include an explanation for changes.
  • Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
  • Component Leads (Review): Please review the Range Diff(s) above to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting /audit override.

Be familiar with the rules and guidelines for writing backports.


🛟 Need Help?

If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.

📋 Component Lead / Release Manager

To override the audit failure, apply releng-audit-override label or comment /audit override.


⚠️ Note: Automated audit checks will be suspended on future pushes to prevent comment spam while you work.

When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.

View workflow run

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label Dec 2, 2026

@ronen-fr ronen-fr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. As this is a backport, I won't bother noting some nits and suggested fix.

cupnes pushed a commit to cupnes/ceph that referenced this pull request Dec 3, 2026
Scrubber::run() opened a fresh omap_iterate over purged_snaps, from its
start, for every mapping key: O(M*P).  On snapshot-heavy OSDs this
pinned a core for days.

Collect the purged_snaps rows once up front, sort them numerically by
(pool, begin), merge overlapping and adjacent same-pool rows into
disjoint ranges, and binary-search them per mapping key: O(M log P).

The numeric sort also fixes missed strays: with pools ordered as
decimal strings, the old walk could stop at a pool-20 row and never
reach pool 3.

The on-disk key order is not numeric in the pool (decimal string), and
rows of one pool may overlap or touch (record_purged_snaps() merges a
new interval only with rows already on disk, so intervals carried in
one call do not see each other), so the merged ranges stay sorted by
(pool, begin) and disjoint: one upper_bound per mapping key, and the
last row that starts at or before the snap is the only one that can
cover it.

Adds unittest_scrubber_run, a unit test for Scrubber::run(): it
builds a SnapMapper over a MemStore and fills it through the same
writer methods ceph-osd uses (record_purged_snaps(), add_oid()),
then checks every stray the scrub reports.

Fixes: https://tracker.ceph.com/issues/81592
Fixes: https://tracker.ceph.com/issues/81798
Signed-off-by: Ante Kuspilic <[email protected]>
(cherry picked from commit 43ce7a9)

Conflicts:
	src/test/test_scrubber_run.cc
	- No git conflict; manual test-only change. The test creates its
	  MemStore with an empty path, which relies on MemStore's
	  in-memory-only mode from 2e8eee3 (PR ceph#71931). umbrella lacks
	  that commit, so the fixture uses a temporary directory instead,
	  as in the tentacle backport (PR ceph#74456). No production code change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build/ops ci-approved core releng-audit-fail Release engineering: failed backport verification audit. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants