Repository navigation
osd/SnapMapper: stop rescanning purged_snaps per mapping key - #72544
Conversation
|
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 |
|
Hi @ronen-fr! Would mind a quick look? |
will do. Interesting premise |
ronen-fr
left a comment
There was a problem hiding this comment.
Thanks for catching this issue.
Please open a tracker for the scenario where entries are missed.
Apart from that: the production code is almost there. See some comments.
The test needs some work.
| // ADJACENT rows), so maxend[] carries the max end of the same-pool | ||
| // rows up to each row: every same-pool row with begin <= snap may | ||
| // cover the snap, not just the last one. | ||
| std::vector<std::tuple<int64_t, snapid_t, snapid_t>> purged; |
There was a problem hiding this comment.
Please declare a structure, with meaningful member names, instead of a tuple.
There was a problem hiding this comment.
Done, the rows are now a purged_range_t struct with pool/begin/end.
| // Build-day integration copy of tests/test_scrubber_run_draft.cc | ||
| // (draft kept intact in the lab pack; fixes live HERE only). | ||
| // | ||
| // Fixes applied vs the draft, all verified against stock v20.2.1 sources: |
There was a problem hiding this comment.
There are many development-time details here (like this line) and below.
A cleanup pass is required.
There was a problem hiding this comment.
Stripped, the header now says what the test does, nothing about how it got here.
|
|
||
| // one purged row byte-identical to what make_purged_snap_key()/ | ||
| // make_purged_snap_key_value() (SnapMapper.cc) write — bypasses | ||
| // record_purged_snaps()'s adjacent-join, which can never leave the |
There was a problem hiding this comment.
The comment seems to be wrong
There was a problem hiding this comment.
Updated to reflect the rewrite.
|
@rzarzynski - seems that the reason we do not have this problem in Crimson, is that we didn't yet get to implementing the whole 'purge left-over snaps' loop. Is it just a matter of priorities? |
|
@ronen-fr: I bet so. |
|
@ronen-fr thanks. I'm working through all the comments now. I'll create the missed-entries scenario in its own tracker, as you suggested. |
c51b374 to
b381d21
Compare
|
References: https://tracker.ceph.com/issues/81798 can be 'Fixes:', too. You do fix that one. |
ronen-fr
left a comment
There was a problem hiding this comment.
Almost there. Some minor nits and fixes.
If you can finish the next round of changes before I go on PTO on Tuesday - I'll try to reread it with priority.
| // can cover it | ||
| auto it = std::upper_bound( | ||
| purged.begin(), purged.end(), | ||
| std::pair(mapping.hoid.pool, mapping.snap), |
There was a problem hiding this comment.
This would also work:
auto it = std::upper_bound(purged.begin(), purged.end(),
purged_range_t{mapping.hoid.pool, mapping.snap, 0});
| m["QSN_garbage"] = garbage; | ||
| raw_omap_set(purged_snaps_hoid, std::move(m)); | ||
| expect_strays({stray_of(1, 15), stray_of(3, 35)}, scrub()); | ||
| } No newline at end of file |
There was a problem hiding this comment.
Note the '(-)' marker: missing a trailing \n
| pool, mapping.snap, mapping.hoid.get_hash(), | ||
| shard | ||
| mapping.hoid.pool, mapping.snap, | ||
| mapping.hoid.get_hash(), shard |
There was a problem hiding this comment.
use spaces for the indentation
| derr << "omap_iterate() on purged_snaps_hoid returns " << r << dendl; | ||
| return; | ||
| } | ||
| std::sort(purged.begin(), purged.end()); |
There was a problem hiding this comment.
switch order with the is-empty check.
| using stray_tuple_t = | ||
| std::tuple<int64_t, snapid_t, uint32_t, shard_id_t>; | ||
|
|
||
| // one purged row as it sits on disk: key (by end-1) and the decoded |
There was a problem hiding this comment.
Dropped in 43ce7a9. The comment described an earlier draft of the struct.
|
|
||
| #include <algorithm> | ||
| #include <map> | ||
| #include <set> |
| target_link_libraries(ceph_test_scrubber_run osd global ${BLKID_LIBRARIES}) | ||
|
|
||
| install(TARGETS | ||
| ceph_test_scrubber_run |
There was a problem hiding this comment.
Important note from Claude (which fixed what I thought to be true):
You must not 'install' the new test. Here is the explanation:
Good questions — I checked, and my nit was understated. It's not dead weight; it would break the package build.
What add_ceph_unittest() actually does
cmake/modules/AddCephTest.cmake:85-93 calls add_ceph_test(), which does three things — the second is the one that matters:
add_test(NAME ${test_name} COMMAND ${test_path} ...)
if(TARGET ${test_name})
add_dependencies(tests ${test_name})
set_property(TARGET ${test_name} PROPERTY EXCLUDE_FROM_ALL TRUE) # <--
endif()So a add_ceph_unittest target is removed from all and only built by the tests target. Verified in your own build dir: src/test/all contains bin/ceph_test_snap_mapper but not bin/unittest_osdmap.
Why combining it with install() breaks
CMake documents installing an EXCLUDE_FROM_ALL target as undefined behavior. In practice, isolated repro of exactly this pattern:
$ ninja # 'all' — binary not built
$ ninja install
CMake Error at cmake_install.cmake:52 (file):
file INSTALL cannot find "/tmp/cmexp/b/ceph_test_demo"
FAILED: CMakeFiles/install.util
And the packaging paths never build tests:
ceph.spec.in:%build→%make_build(=all),%install→%make_install. The%checksection only runsctest, and is conditional onwith make_check.debian/rules: plaindh $@ --buildsystem=cmake, sodh_auto_build(=all) thendh_auto_install.
The only thing that builds the test binaries is run-make-check.sh:90 → build tests — the make-check job, which never installs.
Across all of src/, 260 targets use add_ceph_unittest; zero are also install(TARGETS ...)'d. The two non-unittest_-named ones I cited earlier (ceph_test_object_map, ceph_test_fragmentation_sim) are precedent for the name but neither is installed.
No — teuthology does not use the installed list to run unit tests
Two completely separate pipelines:
| Unit tests | Teuthology | |
|---|---|---|
| Built by | ninja tests (via run-make-check.sh) |
ninja all → ninja install → ceph-test pkg |
| Run by | ctest in the build tree |
explicit references in qa/ |
| Discovery | automatic (add_test) |
none — must be named in a yaml or workunit |
Nothing is auto-discovered on the teuthology side. debian/ceph-test.install has a usr/bin/ceph_test_* glob, so packaging is automatic, but running is not. ceph_test_snap_mapper is run only because one file names it:
qa/suites/rados/singleton-nomsgr/all/ceph-snapmapper.yaml:24
- exec:
client.0:
- ceph_test_snap_mapperFor scale: 162 distinct ceph_test_* targets exist in src/ CMakeLists; only 85 distinct names appear anywhere in qa/. The rest ship in ceph-test and are only ever run by hand on a test node.
So what belongs in the installed set
Install a ceph_test_* binary when it needs something make check can't give it — a live cluster, a real OSD/mon, RADOS/RBD/RGW clients, long runtimes — and when a qa yaml or workunit will actually invoke it. Everything that is a self-contained gtest belongs in make check as unittest_*, not installed.
This PR's test is a gtest over a MemStore that finishes in 19 ms. It's a unit test.
Concrete suggestion for the author
Rename to unittest_scrubber_run (or unittest_snapmapper_scrub), keep add_ceph_unittest, drop the install(TARGETS ...) block:
add_executable(unittest_scrubber_run
test_scrubber_run.cc
$<TARGET_OBJECTS:unit-main>
)
add_ceph_unittest(unittest_scrubber_run)
target_link_libraries(unittest_scrubber_run osd global ${BLKID_LIBRARIES})Worth noting this also retroactively justifies their decision not to fold it into test_snap_mapper.cc, as you'd offered: ceph_test_snap_mapper is installed and is not registered with add_ceph_unittest, so new cases added there would run only in that one teuthology job and never in make check. A separate binary was the right call — the name and the install() are what need fixing.
There was a problem hiding this comment.
Done in 43ce7a9: renamed to unittest_scrubber_run and the install() block is dropped.
| ASSERT_NE(nullptr, d); | ||
| path = d; | ||
|
|
||
| store = ObjectStore::create(cct, "memstore", path); |
There was a problem hiding this comment.
You may want to consider running without a path argument ('(cct, "memstore", "")').
You will save the automatic dumping of the whole store on every test.
There was a problem hiding this comment.
If you do accept his change: you do not need and .
And the whole mkdtemp thing
There was a problem hiding this comment.
Done in 43ce7a9: the store now uses an empty path, and the mkdtemp machinery is gone along with , and <system_error>.
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]>
b381d21 to
43ce7a9
Compare
|
43ce7a9: carries a few unasked changes. Found by my review pass before the push.
|
|
@ronen-fr need your final approval |
|
LGTM. Minor nits that should not block approval. I'll add them as comments. |
| mounted = true; | ||
|
|
||
| ch = store->open_collection(coll_t::meta()); | ||
| if (!ch) { |
There was a problem hiding this comment.
nitti nit: open_collection(), when called without the path, can't fail. So - no real need for the 'if'.
Still - not sure this should be fixed. open_collection() implementation may possibly be changed in the future.
| } | ||
|
|
||
| void make_mappings( | ||
| std::vector<std::pair<snapid_t, hobject_t>> entries) { |
There was a problem hiding this comment.
nit: this is just a loop over make_mapping()
| TEST_F(ScrubberRunTest, StrayInsideInterval) { | ||
| make_purged(1, {{snapid_t(10), snapid_t(20)}}); | ||
| make_mappings({{snapid_t(15), mk_hobj(1, "a")}}); | ||
| ASSERT_EQ(1, scrub().size()); |
There was a problem hiding this comment.
A general nit: when comparing to size(), sometimes you use '0', and sometimes '0u'
|
This PR has been added to wip-bharath11-testing-20261027.070430-main. |
|
This is an automated message by src/script/redmine-upkeep.py. I have resolved the following tracker ticket due to the merge of this PR: No backports are pending for the ticket. If this is incorrect, please update the tracker |
…to-stop, crash dir owner) (#40) * Tentacle: carry three upstream fixes as source patches (ADR 0015) Purged-snaps scrub rewrite (ceph/ceph#72544, backport #74456), cephadm OSD redeploy/reconfig ok-to-stop check (#71640, backport #72033) and cephadm crash dir owner (#66559). * Tentacle: carry the OSD/MDS key rotation fix (#72755, ADR 0015) * ADR 0002: punctuation * Tentacle: carry the MDS rogue-reference-to-purging-inode fix (#73861, ADR 0015)
…to-stop, crash dir owner) (#40) * Tentacle: carry three upstream fixes as source patches (ADR 0015) Purged-snaps scrub rewrite (ceph/ceph#72544, backport #74456), cephadm OSD redeploy/reconfig ok-to-stop check (#71640, backport #72033) and cephadm crash dir owner (#66559). * Tentacle: carry the OSD/MDS key rotation fix (#72755, ADR 0015) * ADR 0002: punctuation * Tentacle: carry the MDS rogue-reference-to-purging-inode fix (#73861, ADR 0015)
Scrubber::run()opened a freshomap_iterateoverpurged_snaps,from its start, for every mapping key:
O(M*P). On snapshot-heavyOSDs this pinned a core for days.
Collect the
purged_snapsrows once up front, sort them numerically by(pool, begin), and merge overlapping and adjacent rows of one pool
into disjoint ranges. Then each mapping key needs only one binary
search:
O(M log P)instead ofO(M*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 sort is needed because the on-disk key order is not numeric in
the pool: the pool id is a decimal string, so pool 20 sorts before
pool 3. The merge is needed because the writer can leave rows that
overlap or touch:
record_purged_snaps()merges a new interval onlywith rows already on disk, so intervals carried in one call do not
see each other. Once the ranges are disjoint and sorted, 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 forScrubber::run(): itbuilds 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
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.