Skip to content

neorados/cls/log: fix infinite trim loop on empty data log shards - #68874

Merged
adamemerson merged 6 commits into
ceph:mainfrom
BBoozmen:wip-oozmen-76563
May 26, 2026
Merged

adamemerson merged 6 commits into
ceph:mainfrom
BBoozmen:wip-oozmen-76563

Conversation

@BBoozmen

Copy link
Copy Markdown
Contributor

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

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.

…ite loop

Add two tests that calls trim() loop function directly (the
use_awaitable_t overloads) rather than the single-op wrapper used by
existing tests. Two test cases for the marker-based overload:

- trim_loop_all_entries_by_marker: writes 10 entries, trims all, verifies
  the loop terminates and entries are gone.
- trim_loop_empty_log_by_marker: trims an empty log object, verifying
  the loop terminates on immediate ENODATA.

Without the fix in the following commits, both tests hang indefinitely.

- start a vstart cluster
- run the test: [build] $ ./bin/ceph_test_neocls_log
- the test introduced in this commit stalls forever:
    ...
    RUN      ] neocls_log.trim_loop_all_entries_by_marker <-- stalls forever

Reproduces: https://tracker.ceph.com/issues/76563
Signed-off-by: Oguzhan Ozmen <[email protected]>
@github-actions github-actions Bot added the tests label May 12, 2026
@BBoozmen BBoozmen changed the title Wip oozmen 76563 [WIP] neorados/cls/log: fix infinite trim loop on empty data log shards May 12, 2026
@BBoozmen BBoozmen changed the title [WIP] neorados/cls/log: fix infinite trim loop on empty data log shards neorados/cls/log: fix infinite trim loop on empty data log shards May 12, 2026
@BBoozmen
BBoozmen marked this pull request as ready for review May 12, 2026 20:32
@BBoozmen BBoozmen added wip-oozmen-testing for teuthology integration testing to be used via build-integration-branch.sh needs-qa labels May 13, 2026
BBoozmen added 5 commits May 19, 2026 23:49
The use_awaitable_t overload of trim() has the try-catch for
ENODATA (no_message_available) inside the for(;;) loop. When
cls_log_trim returns ENODATA (i.e., nothing left to trim), the exception is
caught and silently swallowed execution falls through the catch block
back to for(;;), retrying the trim forever.

This should be a rare condition as 3 conditions should be met in a
single-cluster (once configured as multisite):
 - a realm/period exists
 - zone endpoints are configured
 - data_log* objects exist

Since in a properly setup multisite cluster, data churn is continious so
hard to notice. In the case client reported, the multisite cluster was
reverted back to single site so data_logs have no data all the time;
hence, the issue is pronounced.

This fix adds co_return inside the catch block so ENODATA exits the loop.

Fixes: https://tracker.ceph.com/issues/76563
Signed-off-by: Oguzhan Ozmen <[email protected]>
This is essentially the same as previous commit.

The time-based use_awaitable_t overload of trim() has the same
issue as the marker-based overload: the try-catch for ENODATA is inside
the for(;;) loop, so ENODATA is caught and swallowed, causing the loop
to retry forever.

Fixes: https://tracker.ceph.com/issues/76563
Signed-off-by: Oguzhan Ozmen <[email protected]>
RGWDataChangesFIFO::trim: handle ENODATA from empty FIFO: fifo::FIFO::trim()
throws ENODATA (no_message_available) when the FIFO has no parts yet.

This manifests on clusters with rgw_default_data_log_backing=fifo when
trim_entries is called on a shard before any entries have been pushed.

Signed-off-by: Oguzhan Ozmen <[email protected]>
Verify that DataLogBackends::trim_entries does not crash when called
with max_marker() on a single-generation cluster. The bug causes
upper_bound(head_gen)->second to dereference end() (SIGSEGV)
because the only break condition checked be->gen_id == target_gen,
which is never true when target_gen is UINT64_MAX as encoded by
max_marker() and the cluster has only generation 0.

Signed-off-by: Oguzhan Ozmen <[email protected]>
… > head_gen

When a cluster has no sync zones (single-zone), DataLogTrimCR passes
max_marker() as the trim marker, which encodes target_gen = UINT64_MAX
from gencursor(). In DataLogBackends::trim_entries, after trimming the
head (last) generation, the break condition

    if (be->gen_id == target_gen)

is false (e.g. 0 != UINT64_MAX), so the loop attempts its increment
expression:

    be = upper_bound(be->gen_id)->second

upper_bound(head_gen) returns end(), and dereferencing end()->second
causes crash.

Fix: also break when be->gen_id >= head_gen. Once we've trimmed the
head generation there are no further backends in the map, so the
upper_bound dereference in the loop increment will be skipped.

This is a general bug that affects any cluster using max_marker() as a
trim target (i.e. every single-zone deployment).

Signed-off-by: Oguzhan Ozmen <[email protected]>
@BBoozmen
BBoozmen force-pushed the wip-oozmen-76563 branch from 7e8d8fd to 61b6d72 Compare May 20, 2026 14:00
@BBoozmen
BBoozmen requested a review from a team as a code owner May 20, 2026 14:00
@github-actions github-actions Bot added the rgw label May 20, 2026
@BBoozmen

BBoozmen commented May 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Test Results:

Test branch: https://github.com/ceph/ceph-ci/tree/wip-oozmen-trim-main-testing-2026-05-21-1934
Teuthology/QA Results: https://pulpito.ceph.com/?sha1=a9af4432fbeb757ba63d72ab59bc222bfeb67776

2026-05-25T00:38:10.196 INFO:tasks.rgw_multisite_tests:Ran 57 tests in 3847.917s
2026-05-25T00:38:10.196 INFO:tasks.rgw_multisite_tests:FAILED (SKIP=2, failures=2)

Phillip also tested the fix using a tentacle build on the system which originally exposed this issue.

@BBoozmen BBoozmen added TESTED and removed needs-qa wip-oozmen-testing for teuthology integration testing to be used via build-integration-branch.sh labels May 26, 2026
@pschichtel

Copy link
Copy Markdown

yes, this change is deployed to a production cluster since the 20th of May and works without issues.

@adamemerson
adamemerson merged commit e33ecec into ceph:main May 26, 2026
6 checks passed
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.

3 participants