Skip to content

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

Merged
batrick merged 6 commits into
ceph:tentaclefrom
BBoozmen:wip-76818-tentacle
Jul 9, 2026
Merged

batrick merged 6 commits into
ceph:tentaclefrom
BBoozmen:wip-76818-tentacle

Conversation

@BBoozmen

Copy link
Copy Markdown
Contributor

BBoozmen added 6 commits May 26, 2026 19:09
…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]>
(cherry picked from commit fe1a5a5)
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]>
(cherry picked from commit e1a6ed1)
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]>
(cherry picked from commit 7bb4a76)
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]>
(cherry picked from commit 4c5f4df)
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]>
(cherry picked from commit a323441)
… > 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]>
(cherry picked from commit 61b6d72)
@BBoozmen
BBoozmen requested a review from a team as a code owner May 26, 2026 19:10
@BBoozmen BBoozmen added this to the tentacle milestone May 26, 2026
@github-actions github-actions Bot added rgw tests releng-audit-pass Release engineering: passed backport verification audit. labels May 26, 2026
@adamemerson

Copy link
Copy Markdown
Contributor

@anrao19 Please add this to a tentacle batch when you get a chance so it will be ready to merge when the window opens.

@anrao19

anrao19 commented May 29, 2026

Copy link
Copy Markdown
Contributor

@anrao19 Please add this to a tentacle batch when you get a chance so it will be ready to merge when the window opens.

Sure @adamemerson

@anrao19

anrao19 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

pr testing completed and approved by @ivancich , more details : https://tracker.ceph.com/issues/76985.
@BBoozmen , if no further testing is needed then this can be merged

@ivancich

ivancich commented Jun 2, 2026

Copy link
Copy Markdown
Member

@adamemerson Are you able to provide a review for this PR? It passed QA.

@anrao19

anrao19 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

jenkins test make check

@DavePiper

Copy link
Copy Markdown

I'm also keen to see this make it into tentacle.

@cbodley

cbodley commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

pr testing completed and approved by @ivancich , more details : https://tracker.ceph.com/issues/76985.

@batrick would you please merge this?

@batrick
batrick merged commit 3b41c72 into ceph:tentacle Jul 9, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants