Project

General

Profile

Actions

Enhancement #78727

closed
YL AN

notifications: add config option for persistent topic ownership timeout

Enhancement #78727: notifications: add config option for persistent topic ownership timeout

Added by Yuval Lifshitz 4 months ago. Updated 4 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-2014-g9bf2331bfe
Released In:
Upkeep Timestamp:
2026-08-14T06:44:47+00:00

Description

currently hardcoded at 30 seconds.
in tests, and maybe in some production environments this number could be set lower.
see: https://github.com/ceph/ceph/blob/main/src/rgw/driver/rados/rgw_notify.cc#L88

AN Updated by Akshay Nazare 4 months ago Actions #1

Hi Yuval -- I'm Akshay, a new contributor looking to start in RGW/notifications. I'd like to take this one, and wanted to confirm the intended shape before writing any code.

What I traced in main

  • queues_update_period is the 30s constant at rgw_notify.cc L88.
  • failover_time (L91) is queues_update_period * 3, and that is what gets passed as the lock duration to rados::cls::lock::lock() with LOCK_FLAG_MAY_RENEW in process_queues() (L718).
  • The only other consumer is L690, where it sets next_check_time for the queue list refresh.

So today the refresh period and the queue ownership (failover) timeout are the same knob, related by a hardcoded factor of 3.

Two ways to expose it

(a) One option for the period, default 30s, leaving failover_time as period * 3. Smallest change, one knob to document, and it matches the line the ticket points at.

(b) Separate options for the refresh period and the ownership timeout. More flexible, but it lets an operator set the failover timeout shorter than the refresh period, in which case a lock could expire before the owning daemon renews it and two RGWs could both believe they own the same queue. That would need a clamp or a validation.

I'd propose (a) unless you want the failover timeout tunable independently.

Startup-only or runtime-observable?

The neighbouring rgw_topic_persistency_* options all carry flags: [startup], so matching them is the low-risk choice. But test_bn.py sets options at runtime via ceph config set (e.g. rgw_kafka_max_batch_size around L6243), and a startup-flagged option would not take effect that way without restarting the RGW -- which is somewhat at odds with the "in tests this could be set lower" motivation in the ticket. Reading the value inside the process_queues() loop would make it live-tunable. I don't want to widen the change beyond what you asked for, so I'd rather ask than guess.

Plan for the patch

  • The option in src/common/options/rgw.yaml.in, next to the rgw_topic_persistency_* block -- type: uint, seconds, with a min: guard, following rgw_reshard_thread_interval as the template.
  • The change in rgw_notify.cc, initialised from the constructor's _cct parameter rather than the cct member, since cct is declared at L92 after the timing members.
  • A confval entry in doc/radosgw/notifications.rst alongside rgw_bucket_persistent_notif_num_shards.

On naming I was thinking rgw_topic_ownership_update_period, following the existing rgw_topic_* convention -- happy to take a better suggestion.

Test timings (separate question)

test_bn.py has fixed waits that exist because of this period: time.sleep(30) at L5610, L5705 and L6266, sleep(40) at L1731, sleep(180) at L3249. Being able to lower the period would cut real time off notification test runs. I'd keep that out of this PR and offer it as a follow-up, unless you'd rather see them together.

If the approach looks right, could I be assigned this? And if it's already spoken for, or there's something else in notifications you'd rather see picked up first, I'm happy to take the pointer.

YL Updated by Yuval Lifshitz 4 months ago Actions #2

  • keep one config option (option a) - with the other computed similar to the current code
  • this could be runtime configurable. every time we check the time we can read the timeout from the config option.
    one thing that requires investigation here - need to make sure that if we decrease the time (e.g. from 30s to 9s) we should make sure that ownership does not move unnecessarily because a different RGW calculated 9*3=27 and noticed that a timeout has passed, while the original owner was about to renew after 30s.

regarding tests, IIRC, do we have topic failover tests in test_bn.py. such a test would require taking down an RGW, and i dont think we have the infrastructure for that.
would be nice to add a topic failover test (that can also cover changing the config option) - but should probably be done i na separate PR.
for this PR, a manual failover test (and regressio ncoverage) would probably be sufficient.

please check, but the "sleep()" calls are probably covering other types of timeouts.

AN Updated by Akshay Nazare 4 months ago Actions #3

I checked the sleep() calls, and you were right—they all cover other timeout mechanisms.

1731 (40s): Connection idleness.
3249 (180s): Waits for reservations to become stale before queue deletion.
5610 and 5705 (30s): Topic statistics settling.
6266 (30s): Asserts that the queue does not drain.

None of these are gated on queues_update_period.

There is also no RGW ownership failover test. kafka_failover (pytest.ini:7) tests broker failover, while test_bn.py:3204 kills radosgw and even leaves a TODO: start the radosgw comment at line 3207.

Regarding the decrease case, cls_lock.cc:85 trims lockers based on the stored expiration time using the OSD clock, and the caller-provided duration is only used to compute the new expiration. As a result, if an RGW computes 9 * 3 = 27, it cannot expire the current owner early; it simply receives EBUSY until the stored expiration has passed.

On the owner side, next_check_time is only recomputed in the branch that actually performs the ownership update. Therefore, lowering the option does not shorten an interval that is already in flight. Instead, the next ownership check writes both the new update period and the corresponding new lock duration based on the same configuration read. The trade-off is that a reduced value only takes effect after waiting for up to one previously configured update period.

The patch keeps a single option, rgw_topic_ownership_update_period, while continuing to compute the lock duration as 3 × update_period. The option name is only a suggestion.

Regarding the minimum value, I currently have min = 1. With an update period of 1 second, the lease expires after 3 seconds while the ownership loop polls every second, meaning a renewal can occur roughly 2 seconds into the lease. Would it make more sense to use a higher minimum, such as 5 seconds?

For testing, my plan is to include manual failover testing and regression coverage in this PR, while adding an automated failover test in a separate PR.

YL Updated by Yuval Lifshitz 4 months ago Actions #5

  • Status changed from New to Fix Under Review
  • Pull request ID set to 70956

YL Updated by Yuval Lifshitz 4 months ago Actions #6

  • Status changed from Fix Under Review to Resolved
  • Assignee set to Akshay Nazare

UB Updated by Upkeep Bot 4 months ago Actions #7

  • Merge Commit set to 9bf2331bfe152d38e1540de48fef67c2ac590f71
  • Fixed In set to v21.3.0-2014-g9bf2331bfe
  • Upkeep Timestamp set to 2026-08-14T06:44:47+00:00
Actions

Also available in: PDF Atom