Skip to content

osd: keep a newer entry's missing item for skipped partial writes - #72260

Merged
SrinivasaBharath merged 1 commit into
ceph:mainfrom
vitaly-goot:vgoot/fastec/divergent-skipped-partial-write
Nov 13, 2026
Merged

SrinivasaBharath merged 1 commit into
ceph:mainfrom
vitaly-goot:vgoot/fastec/divergent-skipped-partial-write

Conversation

@vitaly-goot

@vitaly-goot vitaly-goot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes: https://tracker.ceph.com/issues/81225

With allow_ec_optimizations, PGLog::_merge_object_divergent_entries() can undo the missing entry that merge_log() has just added for a newer authoritative update of an object. This happens on a shard where every divergent entry of the object is a partial write that skipped the shard.

It is a regression from #68727 (f4237ca, https://tracker.ceph.com/issues/75962). Since that change, the "more recent entry found, already merged" case requires a kept entry (!entries.empty()). These objects therefore fall through to case 2 or 3 with the skipped entry's prior_version. Example: shard 2 of a 4+2 pool, a divergent 10'100 (prior_version 10'99) that skipped it, and 11'110 in the authoritative log:

Missing item after merge_log() added 11'110 After the divergent merge
need 11'110, have 10'99 (object was not missing) removed (case 3: have == prior_version)
need 11'110, have 9'50 (object already missing) need lowered to 10'99 (case 3)
need 11'110, have 0 (both entries create the object) removed, and the object deleted (case 2)
need 11'110, have 11'105 (a newer partial write 11'105 also skipped the shard, then 11'110 wrote it) need lowered to 10'99, below have (case 3)

The fourth row comes from Alex Ainscow's fault-injection testing on a 4+2 pool: it tripped the "unexpected need for missing item" assert in MissingLoc::add_active_missing(), the assert of https://tracker.ceph.com/issues/73249, with a different cause.

Only nonprimary shards are affected, because partial writes always write shard 0 and the parity shards. In the current interval the primary still recovers the object, because it computed the peer's missing before this merge. But the shard persists the wrong missing set. If the PG re-peers before the object is recovered, the object is not recovered on that shard. The tracker has the sequence and the logs.

Affected:

It needs backports to umbrella and tentacle before tentacle's next release.

Fix

When every divergent entry skipped the shard and the log has a newer entry for the object, return before cases 2 and 3. The divergent entries never touched the object on this shard, and missing already reflects the newer entries. Without a newer entry the merge still rolls missing back, as #68727 intended.

Testing

Unit tests in src/test/osd/TestPGLog.cc:

  • New: PGLogTest.merge_log_skipped_partial_write_then_newer_entry runs the three rows above through merge_log() on shard 2 of a 4+2 pool. It also runs the case osd: Correct missing list on divergent merge of partial writes #68727 fixed (no newer entry: need goes back to prior_version).
  • Updated: test case 7 of PGLogTest.merge_object_divergent_entries_partial_writes was meant to cover case 1 with a partial write. Its log did not index objects, so case 1 never ran. The log is now indexed, and the test also checks need.

Both fail without the fix and pass with it, and the rest of unittest_pglog passes. These runs used a v20.2.4 tree with the tentacle backport of #68727 (#70570). On main, _merge_object_divergent_entries() differs only in whitespace and in trim_after_remove(), which this path does not reach.

TODO: unittest_pglog result on this branch.

Review notes

  • The new check sits next to case 1 rather than widening it. Case 1 clears have, marks the object dirty and removes it, which is right for an object the divergent entries changed. Here they did not change it. If the newer entries also skipped the shard, the object is not in missing, and removing it would drop data that nothing recovers.
  • entries is empty only when every non-error divergent entry was skipped, so last is the newest skipped entry.

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)

@vitaly-goot
vitaly-goot requested a review from a team as a code owner September 30, 2026 20:04
@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.

@aainscow

Copy link
Copy Markdown
Contributor

We are still looking into this.

@bill-scales bill-scales 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

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath14-testing-20261027.071324-main.

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

Please add the extra test. We don't need to re-run QA for an additional test - just make check passing is good enough.

Comment thread src/test/osd/TestPGLog.cc Resolved
merge_log() adds the authoritative entries after the divergence point to
missing before it merges the divergent ones. When every divergent entry
of an object is a partial write that skipped this shard,
_merge_object_divergent_entries() bypasses its "more recent entry
found, already merged" case, which since commit f4237ca ("osd:
Divergent logs for pure partial writes should roll back mising list
when merged") needs a kept entry, and falls through to case 2 or 3.
That undoes the newer entry's missing item:

- missing.have == prior_version (the object was not missing before):
  the item is removed, so the shard is never recovered to the newer
  version;
- otherwise need is rolled back to prior_version, below the version the
  authoritative log requires;
- the divergent entry created the object (prior_version 0): the item is
  removed as for a create;
- a newer partial write that also skipped this shard precedes the newer
  full write: have is that partial write's version (the full write's
  prior_version), and need is rolled back below have.

The divergent entries did not touch the object on this shard, and
missing already reflects the newer entries, so leave both alone.

Test case 7 of merge_object_divergent_entries_partial_writes meant to
cover this case but never reached it: its log did not index objects.
Index it and check need. merge_log_skipped_partial_write_then_newer_entry
runs the four cases above through merge_log(), plus the case that
f4237ca fixed (no newer entry: need rolls back to prior_version).

Fixes: https://tracker.ceph.com/issues/81225
Assisted-by: claude-code:claude-opus-5.5
Signed-off-by: Vitaly Goot <[email protected]>
@vitaly-goot
vitaly-goot force-pushed the vgoot/fastec/divergent-skipped-partial-write branch from 6d22d63 to d9cd09f Compare October 28, 2026 01:13
@MattyWilliams22

Copy link
Copy Markdown
Contributor

@SrinivasaBharath
SrinivasaBharath merged commit dda9f78 into ceph:main Nov 13, 2026
19 checks passed
@edwinzrodriguez

Copy link
Copy Markdown
Contributor

It seems this change has introduced a test failure:

the test builds a 4+2 EC pool but never sets pool.size (stays 0). After the stretch-zone change, is_nonprimary_shard calls get_relative_shard, which does shard.id % get_zone_size() with get_zone_size() == 0 results in div-by-zero

13:44:52 [ RUN ] PGLogTest.merge_log_skipped_partial_write_then_newer_entry
13:44:52
*** Caught signal (Floating point exception) **
13:44:52 in thread 74da9842a400 thread_name:unittest_pglog
13:44:52 ceph version Development (no_version) vampire (dev - Debug)
13:44:52 1: /ceph/build/bin/unittest_pglog(+0x1411a04) [0x5d37803e9a04]
13:44:52 2: /lib/x86_64-linux-gnu/libc.so.6(+0x424b0) [0x74da98f674b0]
13:44:52 3: (pg_pool_t::get_relative_shard(shard_id_t) const+0x56) [0x5d377fffd7d6]
13:44:52 4: (pg_pool_t::is_nonprimary_shard(shard_id_t) const+0x52) [0x5d377fffd702]
13:44:52 5: (pg_missing_set::add_next_event(pg_log_entry_t const&, pg_pool_t const&, shard_id_t)+0x461) [0x5d377ffcb871]
13:44:52 6: (bool PGLog::append_log_entries_update_missing<pg_missing_set >(hobject_t const&, std::__cxx11::list<pg_log_entry_t, mempool::pool_allocator<(mempool::pool_index_t)22, pg_log_entry_t> > const&, bool, PGLog::IndexedLog*, pg_missing_set&, PGLog::LogEntryHandler*, pg_pool_t const&, shard_id_t, DoutPrefixProvider const*)+0x394) [0x5d37800a0694]
13:44:52 7: (PGLog::merge_log(pg_info_t&, pg_log_t&&, pg_shard_t, pg_info_t&, pg_pool_t const&, pg_shard_t, PGLog::LogEntryHandler*, bool&, bool&, bool)+0x149e) [0x5d378009469e]
13:44:52 8: /ceph/build/bin/unittest_pglog(+0xfdf93e) [0x5d377ffb793e]
13:44:52 9: (PGLogTest_merge_log_skipped_partial_write_then_newer_entry_Test::TestBody()+0x2a9) [0x5d377ffb4da9]
13:44:52 10: (void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const)+0x74) [0x5d378008b564]
13:44:52 11: (void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const)+0x66) [0x5d378006a3a6]
13:44:52 12: (testing::Test::Run()+0xb7) [0x5d378004b017]
13:44:52 13: (testing::TestInfo::Run()+0x10f) [0x5d378004ba2f]
13:44:52 14: (testing::TestSuite::Run()+0x17a) [0x5d378004c24a]
13:44:52 15: (testing::internal::UnitTestImpl::RunAllTests()+0x418) [0x5d378005c0a8]
13:44:52 16: (bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const)+0x74) [0x5d378008cd34]
13:44:52 17: (bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const)+0x66) [0x5d378006c826]
13:44:52 18: (testing::UnitTest::Run()+0xb6) [0x5d378005bc36]
13:44:52 19: (RUN_ALL_TESTS()+0x11) [0x5d377ff69571]
13:44:52 20: main()
13:44:52 21: /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x74da98f4ed90]
13:44:52 22: __libc_start_main()
13:44:52 23: _start()
13:44:52 2026-11-16T18:44:50.570+0000 74da9842a400 -1 *** Caught signal (Floating point exception) **
13:44:52 in thread 74da9842a400 thread_name:unittest_pglog
13:44:52
13:44:52 ceph version Development (no_version) vampire (dev - Debug)
13:44:52 1: /ceph/build/bin/unittest_pglog(+0x1411a04) [0x5d37803e9a04]
13:44:52 2: /lib/x86_64-linux-gnu/libc.so.6(+0x424b0) [0x74da98f674b0]
13:44:52 3: (pg_pool_t::get_relative_shard(shard_id_t) const+0x56) [0x5d377fffd7d6]
13:44:52 4: (pg_pool_t::is_nonprimary_shard(shard_id_t) const+0x52) [0x5d377fffd702]
13:44:52 5: (pg_missing_set::add_next_event(pg_log_entry_t const&, pg_pool_t const&, shard_id_t)+0x461) [0x5d377ffcb871]
13:44:52 6: (bool PGLog::append_log_entries_update_missing<pg_missing_set >(hobject_t const&, std::__cxx11::list<pg_log_entry_t, mempool::pool_allocator<(mempool::pool_index_t)22, pg_log_entry_t> > const&, bool, PGLog::IndexedLog*, pg_missing_set&, PGLog::LogEntryHandler*, pg_pool_t const&, shard_id_t, DoutPrefixProvider const*)+0x394) [0x5d37800a0694]
13:44:52 7: (PGLog::merge_log(pg_info_t&, pg_log_t&&, pg_shard_t, pg_info_t&, pg_pool_t const&, pg_shard_t, PGLog::LogEntryHandler*, bool&, bool&, bool)+0x149e) [0x5d378009469e]
13:44:52 8: /ceph/build/bin/unittest_pglog(+0xfdf93e) [0x5d377ffb793e]
13:44:52 9: (PGLogTest_merge_log_skipped_partial_write_then_newer_entry_Test::TestBody()+0x2a9) [0x5d377ffb4da9]
13:44:52 10: (void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const)+0x74) [0x5d378008b564]
13:44:52 11: (void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const)+0x66) [0x5d378006a3a6]
13:44:52 12: (testing::Test::Run()+0xb7) [0x5d378004b017]
13:44:52 13: (testing::TestInfo::Run()+0x10f) [0x5d378004ba2f]
13:44:52 14: (testing::TestSuite::Run()+0x17a) [0x5d378004c24a]
13:44:52 15: (testing::internal::UnitTestImpl::RunAllTests()+0x418) [0x5d378005c0a8]
13:44:52 16: (bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const)+0x74) [0x5d378008cd34]
13:44:52 17: (bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const)+0x66) [0x5d378006c826]
13:44:52 18: (testing::UnitTest::Run()+0xb6) [0x5d378005bc36]
13:44:52 19: (RUN_ALL_TESTS()+0x11) [0x5d377ff69571]
13:44:52 20: main()
13:44:52 21: /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x74da98f4ed90]
13:44:52 22: __libc_start_main()
13:44:52 23: _start()
13:44:52 NOTE: a copy of the executable, or objdump -rdS <executable> is needed to interpret this.
13:44:52
13:44:52 --- begin dump of recent events ---

@vitaly-goot

Copy link
Copy Markdown
Contributor Author

It is a bug in the test only, not in the fix.

The test built its 4+2 pool by hand without pool.size, which was harmless until #72644 started mapping shards by zone a few hours after this merged, so neither PR's CI saw the combination.

It is fixed on main by #73945 (222b177, pool.size = 6), merged 2026-11-17 06:58 UTC. A rebase onto the current main picks it up.

For the backports of https://tracker.ceph.com/issues/81225: 222b177 should go along wherever #72644 is present

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants