Skip to content

tentacle: osd/SnapMapper: purged_snaps scrub misses strays when pool ids have different digit lengths - #74463

Open
Mounika-max-348 wants to merge 2 commits into
ceph:tentaclefrom
Mounika-max-348:wip-83666-tentacle
Open

Mounika-max-348 wants to merge 2 commits into
ceph:tentaclefrom
Mounika-max-348:wip-83666-tentacle

Conversation

@Mounika-max-348

@Mounika-max-348 Mounika-max-348 commented Nov 29, 2026 •

Copy link
Copy Markdown

backport tracker: https://tracker.ceph.com/issues/#83670
backport tracker: https://tracker.ceph.com/issues/83058


backport of #72544
also includes 2e8eee3 from #71931 (needed by unittest_scrubber_run)
parent trackers: https://tracker.ceph.com/issues/81592, https://tracker.ceph.com/issues/81798

this backport was staged using git cherry-pick -x

Scrubber::run() rescanned purged_snaps from the start for every mapping key (O(M*P)), and because pools were ordered as decimal strings, the walk could stop at a pool-20 row and never reach pool 3, missing strays. The original commit collects and sorts the purged_snaps rows numerically once, merges them into disjoint ranges, and binary-searches them per mapping key (O(M log P)). It also adds unittest_scrubber_run.

Conflicts:

  • src/osd/SnapMapper.cc: tentacle still uses assert() instead of ceph_assert() in Scrubber::run(); dropped those asserts as the original commit does. No other changes from the original commit.
  • src/test/osd/PGBackendTestFixture.{cc,h} (from 2e8eee3): files don't exist on tentacle; dropped those hunks.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

@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 github-actions Bot added this to the tentacle milestone Nov 29, 2026
github-actions[bot]

This comment was marked as outdated.

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label Nov 29, 2026
@Mounika-max-348

Copy link
Copy Markdown
Author

The original commit 43ce7a9 fixes both #81592 and #81798, so this PR covers tentacle backport trackers #83666 and #83058; I've added both to the description.

The remaining audit item ("#81798 has no tentacle backport tracker") needs the Backport field on #81798 adjusted, which I don't have permission to change. Could a maintainer please fix it, review the documented assert()/ceph_assert() conflict resolution, and add ci-approved?

/audit retest

@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.

The new test doesn't work on tentacle (src/test/test_scrubber_run.cc:79). The test creates its MemStore with an empty path (ObjectStore::create(cct, "memstore", "")). That only works with MemStore's in-memory mode, which came in with commit 2e8eee3 ("memstore: support in-memory-only mode (empty path)"). That commit is on main but not on upstream/tentacle, where mkfs() builds file paths from the empty path and tries to open /fsid.tmp:

Run as a normal user, it gets -EACCES, so ASSERT_EQ(0, store->mkfs()) fails in all 19 tests.
Run as root, it writes /fsid, /collections, /type and the collection files into /.
Fix: include 2e8eee3 in this backport, or give each test its own temp directory.

aainscow and others added 2 commits November 30, 2026 13:19
Small unit tests built around MemStore (e.g. PGBackendTestFixture) had
to create a real directory on disk for every test run, just to satisfy
MemStore's assumption that it always persists its state to a path.

When MemStore is constructed with an empty path, skip all disk I/O:
- mount/umount skip _load()/_save()
- mkfs skips writing the collections file on disk
- write_meta/read_meta use an in-memory map (meta_map) instead of
  the on-disk ObjectStore::write_meta/read_meta implementation

Also update PGBackendTestFixture to exploit the new mode: pass an
empty path to MockStore so tests no longer create a temporary directory
on disk, removing the mkdir/cleanup_data_dir machinery entirely.

Assisted-by: Claude Sonnet 5 <[email protected]>
Assisted-by: IBM Bob v2.1.0
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit 2e8eee3)

Conflicts:
	src/test/osd/PGBackendTestFixture.cc
	src/test/osd/PGBackendTestFixture.h
	  - these files do not exist in tentacle; dropped those hunks and
	    kept only the MemStore changes, which unittest_scrubber_run
	    (backported next) needs for its empty-path MemStore
Signed-off-by: Mounika <[email protected]>
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/osd/SnapMapper.cc
	  - tentacle still uses assert() instead of ceph_assert() in
	    Scrubber::run(); dropped those asserts as the original commit does
Signed-off-by: Mounika <[email protected]>
@Mounika-max-348

Copy link
Copy Markdown
Author

Hi @ronen-fr ! Thanks for catching this! I've included 2e8eee3 ("memstore: support in-memory-only mode (empty path)") as the first commit, so the empty-path MemStore used by unittest_scrubber_run works on tentacle. Its MemStore changes apply cleanly; the PGBackendTestFixture hunks were dropped because that fixture doesn't exist on tentacle (documented in the Conflicts: section of the commit message).

@Mounika-max-348

Copy link
Copy Markdown
Author

/audit retest

@github-actions

Copy link
Copy Markdown

🔄 Audit Retest Triggered by @Mounika-max-348.

View workflow run

@github-actions github-actions Bot removed the releng-audit-fail Release engineering: failed backport verification audit. label Nov 30, 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

Automated Redmine Linkage Audit

The following tracking irregularities were found:

  • Missing Backport Tracker: Main tracker #80674 does not have a backport tracker for tentacle. Please adjust the 'Backport' field on the main tracker appropriately and remove 'backport_processed' from 'Tags (freeform)'.
  • Missing PR Link: Backport tracker #83670 has no 'Pull Request ID' field set. Please link it to PR #74463.
  • Missing PR Link: Backport tracker #83058 has no 'Pull Request ID' field set. Please link it to PR #74463.

Automated Backport Parity Review - Multiple PRs Detected

This backport appears to pull commits from multiple main PRs including: PR #71931, PR #72544.

This must be made explicit in the backport PR description. Furthermore, each backport tracker ticket associated with these main PRs must be linked to this PR.


Commit Parity Visualizer

BACKPORT PR #74463 SOURCE PR SOURCE STATUS
7ec891d memstore: support in-memory-only mode (empty path) PR #71931 2e8eee3 memstore: support in-memory-only mode (empty path)
f17c474 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 7ec891d (cherry-pick of 2e8eee3)

Affected File(s)

Range Diff

Click to expand
--- Original (2e8eee3b)
+++ Backport (7ec891d0)
@@ -17,3 +17,12 @@
 Assisted-by: Claude Sonnet 5 <[email protected]>
 Assisted-by: IBM Bob v2.1.0
 Signed-off-by: Alex Ainscow <[email protected]>
+(cherry picked from commit 2e8eee3bb5055a246ffa7eb439f2d7cf36fe101f)
+
+Conflicts:
+	src/test/osd/PGBackendTestFixture.cc
+	src/test/osd/PGBackendTestFixture.h
+	  - these files do not exist in tentacle; dropped those hunks and
+	    kept only the MemStore changes, which unittest_scrubber_run
+	    (backported next) needs for its empty-path MemStore
+Signed-off-by: Mounika <[email protected]>

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

1:  2e8eee3bb50 ! 1:  7ec891d0661 memstore: support in-memory-only mode (empty path)
    @@ Commit message
         Assisted-by: Claude Sonnet 5 <[email protected]>
         Assisted-by: IBM Bob v2.1.0
         Signed-off-by: Alex Ainscow <[email protected]>
    +    (cherry picked from commit 2e8eee3bb5055a246ffa7eb439f2d7cf36fe101f)
    +
    +    Conflicts:
    +            src/test/osd/PGBackendTestFixture.cc
    +            src/test/osd/PGBackendTestFixture.h
    +              - these files do not exist in tentacle; dropped those hunks and
    +                kept only the MemStore changes, which unittest_scrubber_run
    +                (backported next) needs for its empty-path MemStore
    +    Signed-off-by: Mounika <[email protected]>
     
      ## src/os/memstore/MemStore.cc ##
     @@ src/os/memstore/MemStore.cc: bool operator>(const MemStore::CollectionRef& l,
    @@ src/os/memstore/MemStore.h: public:
        uint64_t estimate_objects_overhead(uint64_t num_objects) override {
          return 0; //do not care
        }
    -
    - ## src/test/osd/PGBackendTestFixture.cc ##
    -@@ src/test/osd/PGBackendTestFixture.cc: void PGBackendTestFixture::update_osdmap(
    -   event_loop->run_until_idle();
    - }
    - 
    --void PGBackendTestFixture::cleanup_data_dir()
    --{
    --  // Only clean up if the directory exists and hasn't been cleaned already
    --  if (!data_dir.empty() && std::filesystem::exists(data_dir)) {
    --    std::error_code ec;
    --    std::filesystem::remove_all(data_dir, ec);
    --    // Silently ignore errors during cleanup - we tried our best
    --  }
    --}
    --
    - // Helper function for write_attribute implementation
    - int PGBackendTestFixture::do_write_attribute_impl(
    -   const std::string& obj_name,
    -
    - ## src/test/osd/PGBackendTestFixture.h ##
    -@@
    - 
    - #pragma once
    - 
    --#include <filesystem>
    - #include <memory>
    - #include <random>
    - #include <sstream>
    -@@ src/test/osd/PGBackendTestFixture.h: protected:
    -   uint64_t pool_flags = pg_pool_t::FLAG_EC_OVERWRITES | pg_pool_t::FLAG_EC_OPTIMIZATIONS;
    -   
    -   std::unique_ptr<MockStore> store;
    --  std::string data_dir;
    -   ObjectStore::CollectionHandle ch;
    -   coll_t coll;
    -   
    -@@ src/test/osd/PGBackendTestFixture.h: public:
    - 
    -   explicit PGBackendTestFixture(PoolType type = EC) : pool_type(type)
    -   {
    --    std::random_device rd;
    --    std::mt19937_64 gen(rd());
    --    std::uniform_int_distribution<uint64_t> dis;
    --    uint64_t random_num = dis(gen);
    --    
    --    std::ostringstream oss;
    --    oss << "memstore_test_" << std::hex << std::setfill('0') << std::setw(16) << random_num;
    --    data_dir = oss.str();
    --    
    -     ceph_assert(stripe_unit % 4096 == 0);
    -     ceph_assert(stripe_unit != 0);
    -   }
    --  
    --  ~PGBackendTestFixture() {
    --    // Ensure cleanup happens even if TearDown() wasn't called or failed
    --    cleanup_data_dir();
    --  }
    --  
    -+
    -   void SetUp() override {
    -     ceph::logging::Log::set_prefix_hook(&EventLoop::get_log_prefix);
    --    int r = ::mkdir(data_dir.c_str(), 0777);
    --    if (r < 0) {
    --      r = -errno;
    --      std::cerr << __func__ << ": unable to create " << data_dir << ": " << cpp_strerror(r) << std::endl;
    --    }
    --    ASSERT_EQ(0, r);
    --    
    -+
    -     // Create MockMemStore - contexts are stolen by MockPGBackendListener, so we don't need manual_finisher
    --    store.reset(new MockStore(g_ceph_context, data_dir));
    -+    // Empty path puts MemStore in in-memory-only mode (no on-disk state).
    -+    store.reset(new MockStore(g_ceph_context, ""));
    -     ASSERT_TRUE(store);
    -     ASSERT_EQ(0, store->mkfs());
    -     ASSERT_EQ(0, store->mount());
    --    
    -+
    -     g_conf().set_safe_to_start_threads();
    -     
    -     CephContext *cct = g_ceph_context;
    -@@ src/test/osd/PGBackendTestFixture.h: public:
    -       store.reset();
    -     }
    - 
    --    cleanup_data_dir();
    -     ceph::logging::Log::set_prefix_hook(nullptr);
    -   }
    --  
    -+
    - private:
    -   void setup_ec_pool();
    -   void setup_replicated_pool();
    --  void cleanup_data_dir();
    - 
    - protected:
    -   void initialize_scrub_infra();

Deviation in Backport f17c474 (cherry-pick of 43ce7a9)

Affected File(s)

Range Diff

Click to expand
--- Original (43ce7a9a)
+++ Backport (f17c474a)
@@ -28,3 +28,11 @@
 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 43ce7a9acc0b9c872614a55c26baf43da268063b)
+
+Conflicts:
+	src/osd/SnapMapper.cc
+	  - tentacle still uses assert() instead of ceph_assert() in
+	    Scrubber::run(); dropped those asserts as the original commit does
+Signed-off-by: Mounika <[email protected]>

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

1:  43ce7a9acc0 ! 1:  f17c474ad30 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]>
     
    +    (cherry picked from commit 43ce7a9acc0b9c872614a55c26baf43da268063b)
    +
    +    Conflicts:
    +            src/osd/SnapMapper.cc
    +              - tentacle still uses assert() instead of ceph_assert() in
    +                Scrubber::run(); dropped those asserts as the original commit does
    +    Signed-off-by: Mounika <[email protected]>
    +
      ## 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[{}, {})",

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 Nov 30, 2026
@ronen-fr

Copy link
Copy Markdown
Contributor

The PR description should list #83670 instead of #83666.

@ronen-fr

Copy link
Copy Markdown
Contributor

I am probably not authorized to override the audit. @rzarzynski ?

ronen-fr
ronen-fr previously approved these changes Nov 30, 2026
@Mounika-max-348

Copy link
Copy Markdown
Author

Thanks @ronen-fr for approving changes, And I changed the PR description to #83670 instead of #83666.
May I know any other changes needed?

@ronen-fr
ronen-fr self-requested a review November 30, 2026 14:50
@ronen-fr

Copy link
Copy Markdown
Contributor

I have a problem here - the original author would like to perform the backport himself. I did not notice - sorry - that you are two different people.

@ronen-fr
ronen-fr dismissed their stale review November 30, 2026 14:53

The original PR author opened a backport some 16 hours earlier

@Antek74 Antek74 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.

I authored the original fix (#72544) and the earlier tentacle backport (#74456), and validated 74456 locally.

Review changes belong in the validated PR. If they land in 74463, the code that merges is not the code I tested with the unit suite, ctest, and the OSD-level check. I can apply comments and re-run validation directly, without a relay.

The backport is also urgent: the tracker PR IDs can point to only one PR, so the two cannot both pass backport audit. Until one is closed, the fix stays stuck so @ronen-fr, I suggest you close #74463 as duplicate and continue with #74456; it needs no extra commit and avoids the 80674 audit finding.

@Antek74

Antek74 commented Dec 2, 2026

Copy link
Copy Markdown

Hi @Mounika-max-348 , as in my review above, this PR duplicates #74456, the validated tentacle backport. Ronen has retracted his approval here, and the tracker can link only one PR. Could you close this one as duplicate?
Thanks.

@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.

DNM

Should be closed for #74456

@ronen-fr ronen-fr added the DNM label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants