Skip to content

rgw/admin: radosgw-admin topic dump follows max-entries - #71144

Merged
anrao19 merged 3 commits into
ceph:mainfrom
akkki007:wip-rgw-topic-dump-pagination
Nov 13, 2026
Merged

anrao19 merged 3 commits into
ceph:mainfrom
akkki007:wip-rgw-topic-dump-pagination

Conversation

@akkki007

@akkki007 akkki007 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Problem

--max-entries was only used as the batch size of the calls to the queue. The command itself kept listing until every shard was exhausted, so from the caller's point of view all pending notifications were always dumped in one go, and there was no way to page through a large queue.

Fix

Return at most --max-entries notifications and a marker to continue from.

  • The marker holds both the shard and the position inside it (<shard index>#<queue marker>), because the persistent queue is sharded and a page can end in the middle of a shard.
  • --marker already existed as a global option but was shadowed by a local variable in the handler, so it only needed wiring up.
  • The output is now an object holding the entries under eventEntries, together with truncated and marker, instead of a bare array. The shape is the same whether or not the flags are passed. This changes the output format, so it is called out in PendingReleaseNotes.
  • When --max-entries is not given, everything is dumped as before, just in the new shape. When it is given it is clamped to at least 1, matching what radosgw-admin bi list does.

Two unrelated things in the rewritten block, worth pointing out since they show up in the diff:

  • librados::ObjectReadOperation rop was declared outside both loops and reused. cls_2pc_queue_list_entries appends to the op, so each iteration was sending a progressively larger operation. It is now scoped to the iteration.
  • Two error paths reported cpp_strerror(-ret) while checking rc, printing a stale error code. They now report -rc.

Testing

vstart, one radosgw, a persistent topic with an unreachable endpoint so 23 notifications stayed queued across 11 shards. Paging with --max-entries 5:

page 1: 5 entries, truncated=True,  marker='2#0/25092'
page 2: 5 entries, truncated=True,  marker='6#'
page 3: 5 entries, truncated=True,  marker='8#0/26125'
page 4: 5 entries, truncated=True,  marker='10#'
page 5: 3 entries, truncated=False, marker=''
pages=5 collected=23 expected=23

The pages reassemble into exactly the same set as an unpaginated dump, with no missing and no repeated events. Both marker cases are exercised: 2#0/25092 resumes in the middle of a shard, 6# starts at the next one. No page exceeded the limit, and with no flags at all the output has truncated: false and an empty marker.

Added test_persistent_topic_dump_pagination, which does the same walk: it checks that no page exceeds --max-entries, that the pages hold every event and none of them twice, and that a dump without the flag reports truncated: false and an empty marker. Like test_ps_s3_x_amz_request_id_on_master it uses a wrong endpoint to keep the events queued, so it needs no broker.

test_bn.py also reads the dump in six other places, all updated for the new shape. The new test, test_ps_s3_x_amz_request_id_on_master and test_ps_s3_notification_concurrent_put_eventtime pass locally. test_persistent_topic_dump is a kafka_test and was not run locally for lack of a broker.

Marker validation, and a hang in the queue

Since the marker now comes from the caller, it is checked before the command runs: the shard has to exist, and the position inside it has to be a queue marker. A marker that parses but points past the tail of the shard used to hang the command, and the OSD with it: queue_list_entries() computes contiguous_data_size = head.tail.offset - start_offset, which underflows for a start offset past the tail, and the loop then reads empty chunks past the end of the queue forever. The second commit makes queue_list_entries() check the result of parsing the marker and reject a position that is not between the front and the tail, and adds TestCls2PCQueue.ListInvalidMarker for it.

--marker '0'                    rc=22  ERROR: invalid marker: 0
--marker 'not-a-marker'         rc=22  ERROR: invalid marker: not-a-marker
--marker '11#'                  rc=22  ERROR: invalid marker: 11#
--marker '-1#'                  rc=22  ERROR: invalid marker: -1#
--marker 'shard#'               rc=22  ERROR: invalid marker: shard#
--marker '0#not-a-queue-marker' rc=22  ERROR: invalid marker: 0#not-a-queue-marker
--marker '0#0/99999999'         rc=22  ERROR: could not list entries from queue. error: (22) Invalid argument

ceph_test_cls_2pc_queue (25 tests) and ceph_test_cls_queue (17 tests) pass with the change, including the wrap-around and spillover ones.

Related

Same area as #70956 (merged) and #71092 (open), but independent of both. This branch is cut from main and the only file they have in common is doc/radosgw/notifications.rst, in a different section.

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)

@akkki007
akkki007 requested review from a team as code owners August 19, 2026 02:28
@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.

Comment thread doc/radosgw/notifications.rst Resolved
@akkki007
akkki007 force-pushed the wip-rgw-topic-dump-pagination branch from d3ccd79 to 1534afd Compare August 19, 2026 12:48
@adamemerson

Copy link
Copy Markdown
Contributor

ok to test

@adamemerson
adamemerson requested a review from yuvalif August 19, 2026 15:13
@adamemerson

Copy link
Copy Markdown
Contributor

@yuvalif Please take a look if you can, fix to a bug you reported.

@akkki007

akkki007 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@anrao19

anrao19 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

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

Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
@yuvalif

yuvalif commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@pritha-srivastava would appriciate your review of 2658734 ?
do we have this issue in other cases where the user can provide queue markers?

@yuvalif

yuvalif commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@akkki007 why was the test added to cls 2pc queue and not to cls queue suite?

@yuvalif

yuvalif commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

so a marker like 0#not-a-queue-marker went to the queue as is.

@akkki007 what was the behavior before the fix?

@anrao19 anrao19 removed the TESTED label Sep 16, 2026
@akkki007
akkki007 force-pushed the wip-rgw-topic-dump-pagination branch from 2658734 to 7267ee1 Compare October 12, 2026 04:11
@akkki007

Copy link
Copy Markdown
Contributor Author

Moved it, you are right: the fix is in queue_list_entries() in cls_queue_src.cc, which both classes share, so the generic queue suite is where it belongs. It is now TestClsQueue.ListInvalidMarker in src/test/cls_queue/test_cls_queue.cc, and it is gone from the 2pc suite. Amended into 7267ee1.

[ RUN      ] TestClsQueue.ListInvalidMarker
[       OK ] TestClsQueue.ListInvalidMarker (2120 ms)
[==========] 18 tests from 1 test suite ran. (62009 ms total)
[  PASSED  ] 18 tests.

[==========] 24 tests from 1 test suite ran. (207770 ms total)   # ceph_test_cls_2pc_queue
[  PASSED  ] 24 tests.

@akkki007

Copy link
Copy Markdown
Contributor Author

what was the behavior before the fix?

It was silently taken for the front of the queue, so the dump started from the beginning of the shard instead of reporting anything.

cls_queue_marker::from_str() sets gen first and only then fails, and offset is uint64_t offset{0}, so a marker it could not parse leaves offset at 0. queue_list_entries() ignored that return value, and offset == 0 is how the marker "start from the front" is spelled:

  cls_queue_marker start_marker;
  start_marker.from_str(op.start_marker.c_str());   // result ignored
  ...
  if (start_marker.offset == 0) {
    start_offset = head.front.offset;               // the front, for every unparsable marker
    gen = head.front.gen;

Checked it against the cls from before the fix, on a queue with 20 entries:

PROBE: list with "not-a-marker" returned 0, entries: 20, first entry: op-0-element-0, next marker: 0/1504

With the fix the same call returns -EINVAL, which is what TestClsQueue.ListInvalidMarker asserts, and radosgw-admin topic dump rejects such a marker before it reaches the queue at all.

So the two halves of a bad marker failed differently: a marker that did not parse quietly restarted the listing from the beginning (wrong result, no error), while a marker that parsed but pointed past the tail hung the cls method in the OSD.

@akkki007

Copy link
Copy Markdown
Contributor Author

do we have this issue in other cases where the user can provide queue markers?

topic dump is the only place where a marker reaches the queue from the user. The only other caller is the notification worker, and it does not take one from anywhere: rgw_notify.cc lists with const std::string start_marker; that is never assigned, and the end_marker it hands to cls_2pc_queue_remove_entries() is always the one the preceding list returned.

There is one neighbour worth mentioning, though it is not reachable from outside today: queue_remove_entries() has the same shape as the listing had. It ignores the result of from_str() as well, and an end marker past the tail satisfies its first branch (end_marker.offset > head.front.offset && end_marker.gen == head.front.gen), so it zeroes out end_marker.offset - head.front.offset bytes and then does head.front = end_marker, leaving the front past the tail. Any listing after that starts from a front the queue does not hold, which is exactly the case the fix now rejects. Today only the notification worker calls it, with a marker the queue itself produced, so nothing reaches it — happy to add the same check there in this PR if you want it covered.

The max-entries parameter was only used as the batch size of the calls to
the queue, while the command itself kept listing until every shard was
exhausted, so from the caller's point of view all the entries were always
dumped at once.

Return at most max-entries notifications, and a marker to continue from.
The marker holds both the shard and the position inside it, so a dump can
resume in the middle of a shard. The --marker option already existed but
was shadowed by a local variable, so it is now wired to the command.

The output is now an object holding the entries under "eventEntries",
together with "truncated" and "marker", instead of a bare array. This is
a change of the output format, and is noted in the release notes.

Fixes: https://tracker.ceph.com/issues/78695
Signed-off-by: Akshay Nazare <[email protected]>
Follow up on the review of the pagination of "radosgw-admin topic dump".

The limit on the number of entries returned to the caller is now a const,
so that it is clear it does not change while the shards are listed, and
the shard part of the marker is no longer the only one checked: the
position inside the shard has to be a queue marker as well, otherwise the
marker is rejected.

Extend the test to cover the pagination across shards, a marker that holds
a shard and no position inside it, and the markers that are rejected.

Signed-off-by: Akshay Nazare <[email protected]>
queue_list_entries() ignored the result of parsing the start marker, and
did not check that the position it holds is one that the queue actually
holds. A marker past the tail makes the size of the contiguous data to
read underflow, and the loop then keeps reading empty chunks past the end
of the queue, which never ends: the cls method spins in the OSD until it
is killed.

This was not reachable while the only markers passed to the queue were
the ones it had returned, but "radosgw-admin topic dump" now takes a
marker from the caller, and a marker that was valid can also become stale
once the entries it points at have been consumed.

Parse the marker, and return EINVAL for a position that is not between
the front and the tail of the queue.

Signed-off-by: Akshay Nazare <[email protected]>
@akkki007
akkki007 force-pushed the wip-rgw-topic-dump-pagination branch from 7267ee1 to 310ffde Compare November 3, 2026 18:21
@akkki007
akkki007 requested a review from a team as a code owner November 3, 2026 18:21
@yuvalif

yuvalif commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

do we have this issue in other cases where the user can provide queue markers?

topic dump is the only place where a marker reaches the queue from the user. The only other caller is the notification worker, and it does not take one from anywhere: rgw_notify.cc lists with const std::string start_marker; that is never assigned, and the end_marker it hands to cls_2pc_queue_remove_entries() is always the one the preceding list returned.

There is one neighbour worth mentioning, though it is not reachable from outside today: queue_remove_entries() has the same shape as the listing had. It ignores the result of from_str() as well, and an end marker past the tail satisfies its first branch (end_marker.offset > head.front.offset && end_marker.gen == head.front.gen), so it zeroes out end_marker.offset - head.front.offset bytes and then does head.front = end_marker, leaving the front past the tail. Any listing after that starts from a front the queue does not hold, which is exactly the case the fix now rejects. Today only the notification worker calls it, with a marker the queue itself produced, so nothing reaches it — happy to add the same check there in this PR if you want it covered.

could yopu please open a sepaarte tracker for that?
just in case someone exposes a ranged deletion api for the user.

@anrao19

anrao19 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao16-testing-2026-11-06-0456-main.

@anrao19

anrao19 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao16-testing-2026-11-06-0456-main.

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

@anrao19
anrao19 merged commit fe27c74 into ceph:main Nov 13, 2026
18 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 fe27c74452d84d2eb1c905d1381783cc907f6581^..fe27c74452d84d2eb1c905d1381783cc907f6581

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/43385406548

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.

5 participants