Skip to content

osd/ECExtentCache: hold reads behind a cache invalidation, pin growth holes - #72683

Merged
aainscow merged 2 commits into
ceph:mainfrom
aainscow:wip-ec-invalidate-replay-fix
Nov 18, 2026
Merged

aainscow merged 2 commits into
ceph:mainfrom
aainscow:wip-ec-invalidate-replay-fix

Conversation

@aainscow

@aainscow aainscow commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #72666 (the revert of #70377); only the last two commits are new to this PR. The tests are in #72684.

Fixes two defects in the Fast EC extent cache. The full description is in https://tracker.ceph.com/issues/81754.

1. Reads replayed after a cache invalidation overtake the invalidating write. An op that invalidates the cache (a clone or rollback onto the object, a remove and recreate, a shrinking truncate) waits at the head of the queue. Then ECExtentCache::Object::invalidate() replays the ops queued behind it on the same object and sends their reads at once. The invalidating op's sub-writes are only sent once all the cache ops of its transaction are ready, after those reads. Unless the invalidating op reads something itself, the queued writes read the object as it was before it:

  • below the old size, they get the old data instead of the clone's data, or instead of the zeros a truncate or recreate leaves, and write it back silently;
  • past the old size, the reads are dropped, and a write with no other reads hits ceph_assert(reads_sent).

The reverted #70377 turned the assert into zero-fill (https://tracker.ceph.com/issues/81611). Now the reads of the replayed ops wait for write_done() of the invalidating op, which runs after its sub-writes are sent and sets current_size.

2. A growth hole is erased by an older op's cache line (https://tracker.ceph.com/issues/81315, from #72331, unchanged). The growing op now pins every line its hole spans. This matches the ceph_assert(reads_sent) crash reports on https://tracker.ceph.com/issues/78465 (tentacle 20.2.1/20.2.2).

Both commits cherry-pick cleanly onto tentacle after #72650.

Supersedes #72331 (fix) and, with #72684, #72332 and #72566 (tests).

Results with the tests from #72684, on main with #70377 reverted (10 optimized EC configurations per peering test):

Test main + #72666 + this PR
TestECInvalidateReplay.Rollback abort, ceph_assert(reads_sent) pass 10/10
TestECInvalidateReplay.CachedRollback old data, 10/10 fail pass 10/10
TestECInvalidateReplay.TruncateGrow old data, 10/10 fail pass 10/10
TestECInvalidateReplay.CachedRecreate old data, 10/10 fail pass 10/10
TestECInvalidateReplay.Recreate abort pass 10/10
TestECInvalidateReplay.TruncateGrowShortShard abort pass 10/10
TestECInvalidateReplay.UnalignedTruncate (control) pass 10/10 pass 10/10
TestECRollbackPartialWrites.* (4 tests; 3 zero-fill with #70377) pass 10/10 pass 10/10
TestECFailoverWithPeering.ExtentCacheGrowthHoleErasedByLineDeath abort pass 10/10
ECExtentCache.HoleErasedByOlderOpLineDeath, HoleErasedBeforeReadDoneSendReads abort pass
ECExtentCache.CloneInvalidateStaleSize abort pass
TestBackendBasics.TruncateGrowWithSuspendedReads, RollbackInvalidateRealistic abort pass 96/96

With this PR and #72684 merged into main, all of unittest_ecfailover_with_peering (338), unittest_backend_basics (888), unittest_extent_cache (12), unittest_ecbackend, unittest_ec_with_crush, unittest_ec_transaction, unittest_ecutil, unittest_ec_omap_journal and the _l variants pass. The new and rollback tests passed 600/600 over 5 repeats. Locally, the ctest unit tests pass (218/219: run-cli-tests fails only on radosgw-admin/help.t, as RGW was not built), as do smoke.sh, safe-to-destroy.sh, crush_weights.sh and run-rbd-unit-tests-*.

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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

🤖 Generated with Claude Code

@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 - Blocking reads until the invalidating write calls write_done() is the correct and minimal fix. The write transactions have been submitted by this point so any future read that is issued will not overtake the writes.

Pinning the hole is a reasonable way of stopping reads to that region until the write completes.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath17-testing-20261016.230103-main.

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@aainscow
aainscow force-pushed the wip-ec-invalidate-replay-fix branch from 26ec0f3 to 5a4aacd Compare October 22, 2026 07:14
@aainscow
aainscow marked this pull request as ready for review October 26, 2026 07:35
@aainscow
aainscow requested a review from a team as a code owner October 26, 2026 07:35
When an op grows an object, Object::request() adds the gap between the
old and new projected size to do_not_read, so later ops do not read
data that is not yet on disk. do_not_read entries are erased a line at a
time when the last op pinning the line dies, but the growing op only
pinned the lines of its own reads and writes.

An older op pinning a line inside the hole could therefore die first and
erase that part of the hole while the growing op was still waiting for
its cache_ready, before current_size was updated. A following op would
then send reads in the hole with the old current_size, none survived the
read mask, and do_read_op hit ceph_assert(reads_sent).

Pin every line the hole spans, so that it lives until the growing op
completes.

Fixes: https://tracker.ceph.com/issues/81315
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
An op that invalidates the extent cache (a clone or rollback onto the
object, a remove and recreate, a shrinking truncate) waits at the head of
the queue for the object's reads, then invalidate() clears the cache and
replays every op queued on the object. The replayed ops' reads are sent
straight away, but the invalidating op's write is only issued once all
the cache ops of its transaction are ready, after them. Unless the
invalidating op has reads of its own, the queued ops therefore read the
object as it was before it: the old data instead of the clone's, or
instead of the zeros a truncate or recreate leaves, which they write back
into the parts of their pages they do not overwrite. Reads past the old
size are dropped by the read mask, so a queued op that only reads there
hits ceph_assert(reads_sent).

Hold the reads of the ops replayed behind the invalidating op until
write_done() for it. That runs after its sub-writes have been sent, and
sets current_size to the size the reads are made against.

a970eae (since reverted) avoided the assert by replaying from
current_size, which makes the growth to the invalidating op's size a
hole. For a clone or rollback that region holds the source's data, which
the queued ops replaced with zeros.

Fixes: https://tracker.ceph.com/issues/81754
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
@ljflores

ljflores commented Nov 4, 2026

Copy link
Copy Markdown
Member

@aainscow was the latest force push trivial? Since we don't know, I removed it from the current QA batch and it will be added to the next.

@aainscow

aainscow commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@ljflores force push was a trivial rebase. I have updated my process now to make a note of this in a comment.

@ljflores

ljflores commented Nov 5, 2026

Copy link
Copy Markdown
Member

Thanks for clarifying; we will still consider the results valid.

@RaminNietzsche

Copy link
Copy Markdown
Member

Category: stated-supersede (high)

Description references superseding #72331 and coordinating with #72684. pr-triage lists all three still open. A single canonical PR link in the descriptions may help reviewers.


pr-triage note — automated candidate for human review only, not a maintainer decision. Snapshot 2026-11-10 against open PR bases. pr-triage is a personal read-only assistant by @RaminNietzsche; not affiliated with or endorsed by the Ceph project. Please verify (rebase, git cherry, tracker) before acting.

@bhouse-nexthop

Copy link
Copy Markdown

We hit https://tracker.ceph.com/issues/81754 in production on 20.2.3. It's a 6+2 pool with allow_ec_optimizations holding RBD disks for KVM VMs. OSDs kept aborting with ECCommon.cc:497 FAILED ceph_assert(reads_sent), about every 10-15 minutes somewhere in the cluster.

We built ceph-osd from v20.2.3 with both commits from this PR (as of 367d236) and rolled it to all 54 OSDs at 19:10 UTC yesterday. There hasn't been a reads_sent assert since. That's about 6.5 hours so far, and it includes a large backfill after we added 18 more OSDs.

Thanks for the fix. A tentacle backport would really help us.

@aainscow

Copy link
Copy Markdown
Contributor Author

We hit https://tracker.ceph.com/issues/81754 in production on 20.2.3. It's a 6+2 pool with allow_ec_optimizations holding RBD disks for KVM VMs. OSDs kept aborting with ECCommon.cc:497 FAILED ceph_assert(reads_sent), about every 10-15 minutes somewhere in the cluster.

We built ceph-osd from v20.2.3 with both commits from this PR (as of 367d236) and rolled it to all 54 OSDs at 19:10 UTC yesterday. There hasn't been a reads_sent assert since. That's about 6.5 hours so far, and it includes a large backfill after we added 18 more OSDs.

Thanks for the fix. A tentacle backport would really help us.

I am waiting for RADOS approved following testing. Once that happens, I will make a backport, but it can take a little while to get in.

@Naveenaidu

Copy link
Copy Markdown
Contributor

@aainscow
aainscow merged commit 902adbb into ceph:main Nov 18, 2026
16 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I found one or more Fixes: tags in the commit messages in

git log 902adbbea810e07785939fd70f347dafd74a36c7^..902adbbea810e07785939fd70f347dafd74a36c7

The referenced tickets are:

Those tickets do not reference this merged Pull Request. If this Pull Request merge resolves any of those tickets, please update the "Pull Request ID" field on each ticket. A future run of this script will appropriately update them.

Update Log: https://github.com/ceph/ceph/actions/runs/44261907486

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.

7 participants