Repository navigation
rgw: reload when the period changed while the gateway started - #72852
lumir-sliva wants to merge 3 commits into
Conversation
|
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 |
init_storage() loads the realm and its current period, and the gateway runs with that period until its next reload. The realm watch that triggers reloads is only set up at the end of init_frontends2(), after the frontends are already up, and the reload handler is added to it after that. A period change in between is stored in rados but notifies nobody: before watch2() the notify reaches no watcher, between watch2() and add_watcher() it finds no handler and is dropped. A later push of the same period stops at "already have epoch" in RGWOp_Period_Post and doesn't notify again, so the gateway keeps the old period until it is restarted. With more than one gateway per zone this happens whenever one of them starts while a new period reaches the zone: another gateway takes the push, stores the period and notifies before the starting one watches. Once the last init step is done, read the realm's current period and its latest epoch again. If either differs from the one the site configuration was loaded with, do what the lost notify would have done: hand the period to the period pusher, which sends it on to the zones that still need it when this zone is its master (the pusher only knows the period the driver started with), and schedule a reload. A zone that the current period did not contain yet runs on its local zonegroup, which is how a new zone starts out; for it, reload once the current period contains the zone. RGWRealmReloader gets schedule_reload() for that, split out of handle_notify(). The check is called from main() and RGWLib::init() rather than from init_frontends2(), because the reload replaces env.driver and RGWLib::init() still runs init_lua() and init_dedup() against it after init_frontends2() returns. It compares against a record of what init_storage() loaded rather than against the site configuration, which a reload that a notify triggered in the meantime may already be rewriting. Fixes: https://tracker.ceph.com/issues/81911 Signed-off-by: Lumir Sliva <[email protected]>
rgw_inject_delay_pattern=delay_realm_watch holds a starting gateway with its frontends up but before it watches the realm, for up to rgw_inject_delay_sec seconds or until the pattern is cleared, so a test can land a period change in that window and release the gateway when it is ready, without depending on timing. Fixes: https://tracker.ceph.com/issues/81911 Signed-off-by: Lumir Sliva <[email protected]>
Zone 2's gateways are held with delay_realm_watch, after their frontends are up but before they watch the realm, and the period changes while they are held. test_period_change_during_gateway_startup sets zone 2's redirect_zone to zone 1. Each held gateway must still answer NoSuchKey for an object that only zone 1 has, which shows the change landed in the window. Released, each must reload and answer 301; one that missed the reload stays on the old period and keeps answering NoSuchKey. test_master_change_during_gateway_startup makes zone 2 the master. The commit on zone 2's cluster notifies nobody there, and only zone 2's gateways would send the new period on to zone 1. Released, they must do so: zone 1's cluster must get the period that made zone 2 the master. Both work with one gateway per zone. Fixes: https://tracker.ceph.com/issues/81911 Signed-off-by: Lumir Sliva <[email protected]>
0e39507 to
2e7915c
Compare
|
Force-pushed a reworked version (0e39507 -> 2e7915c), description updated. The first one crashed the librgw path (the reload it scheduled replaced |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
Summary
A radosgw that is still starting when a new period reaches its zone can miss the realm reload and keep running the old period until it's restarted. With more than one gateway per zone, another gateway takes the period push, stores it and notifies, while the starting one isn't watching the realm yet. If the change made the starting gateway's zone the master, the zone that was master before never hears about it either.
Problem
Startup order (
rgw_appmain.ccat ce66551):init_storage()loads the realm and its current period (site.load(), line 301). The gateway runs with that period until its next reload.init_frontends2()starts the frontends (line 619), so the gateway already takes requests, period pushes included.create_realm_watcher(), line 639,watch2()inrealm_watcher.cc:101), and the period pusher and the reload handler are added after that (add_watcher(...), lines 642 and 661).A period change in between is stored in rados but doesn't reload this gateway:
watch2()reaches no watcher;watch2()andadd_watcher()finds no handler and is dropped: "Failed to find a watcher for notify type 1" (realm_watcher.cc:64);RGWOp_Period_Post(rgw_rest_realm.cc:172-178) and returns 200 without notifying.RGWRealmReloader::reload()already guards against this for a reload in progress (rgw_realm_reloader.cc:110, "or we could miss some updates"); startup doesn't.The notify carries two things,
ZonesNeedPeriodfor the period pusher andReloadfor the reloader (driver/rados/config/realm.cc,realm_notify_new_period). Both are lost. The pusher built ininit_frontends2()reads the period the driver started with (rgw_period_pusher.cc:177), so when the change in the window promoted this zone to master, nobody pushes the new period to the old master: it keeps running as master until the next commit.Found with
test_multi_period_incremental_sync_backlogfrom #72670 at 3 zones x 2 gateways: 5 of 5 runs fail because one of zone 3's gateways never reloads after the zone restarts. The test sleepsreconfigure_delay(5 s) and starts zone 3's gateways one after the other, and the master's period pusher retries at +2 s and +6 s, so the +6 s retry lands between the two starts every time.Fix
Once the last init step is done,
AppMain::reload_if_period_changed()reads the realm's current period and its latest epoch again. If either differs from whatinit_storage()loaded, it does what the lost notify would have done, in the same order: it hands the period to the period pusher, which sends it on to the zones that still need it when this zone is its master, and schedules a reload. A zone that the current period did not contain yet runs on its local zonegroup, which is how a new zone starts out; for it, the check reloads once the current period contains the zone. The epoch matters too: an epoch-only change (a zonegroup or zone modify) goes through the reflect path and notifies the same way.The check runs from
main()andRGWLib::init()after the last init step, not insideinit_frontends2(), because the reload replacesenv.driverandRGWLib::init()still runsinit_lua()andinit_dedup()against it afterinit_frontends2()returns. It compares against a record of whatinit_storage()loaded rather than against the site configuration, which a reload that a notify triggered in the meantime may already be rewriting; if such a reload already loaded the new period, the check schedules one more, which is harmless.RGWRealmReloader::schedule_reload()is split out ofhandle_notify()for this, and the reloader keeps itsCephContextinstead of reading it throughenv.driver.The second commit adds
rgw_inject_delay_pattern=delay_realm_watch, which holds a starting gateway with its frontends up but before it watches the realm, until the pattern is cleared orrgw_inject_delay_secelapses.Test
Two tests in
rgw_multi/tests.py. Both hold zone 2's gateways withdelay_realm_watch, change the period while they are held, and clear the pattern to let them continue:test_period_change_during_gateway_startup: zone 2'sredirect_zoneis set to zone 1. Each held gateway must still answer NoSuchKey for an object only zone 1 has, which shows the commit landed in the window; released, each must reload and answer 301.test_master_change_during_gateway_startup: zone 2 is made the master, committed on its own cluster. Zone 1's cluster must still have the old period while zone 2 is held; released, zone 2's gateways must send the new period on, and zone 1's cluster must have it within 60 s.Both work with one gateway per zone. main 04ba07e + this PR (same diff as the branch), vstart,
test_multi.py, 3 zones:test_period_change_during_gateway_startuptest_period_change_during_gateway_startuptest_master_change_during_gateway_startuptest_master_change_during_gateway_startuptest_multi_zone_redirect, one runtest_period_change_during_gateway_startup, recheck disabledstill on the old period (got NoSuchKey, expected 301)test_master_change_during_gateway_startup, pusher replay removedzone 1 never got the period that made zone 2 the masterNew-zone case, scripted: two clusters, zone
zg1-3created on the second one without a commit, its gateway started held, the period that adds the zone committed, gateway released. With the fix the gateway logsrealm's current period ... now contains zone zg1-3, it did not while starting up, reloadingand an object written to the master afterwards is readable through it 15 s later. Without the recheck it never reloads and the object stays unreadable (AccessDenied, no metadata sync on the local zonegroup) until the next period commit.Also reproduced without the injection point, with gdb holding one of two gateways of the secondary zone (non-stop mode, only the main thread halted) while
redirect_zoneis committed, 2 zones x 2 gateways:rgw::AppMain::init_frontends2(before frontends and watch)RGWPeriodPusherconstructor (afterwatch2(), before handlers)And on a tentacle 20.2.4 multisite cluster with two zones of four gateways each: one master-zone gateway restarted held before its realm watch,
period update --commitwhile held (epoch bump), released. With the delay point only it stays on the old epoch, no reload. With this PR:The held gateway received none of the period pushes itself in any run; another gateway of the zone took them, which is the shape of the bug. The reproducer script and the logs of the first round are attached to the tracker.
The branch builds commit by commit on ce66551.
Related: https://tracker.ceph.com/issues/79869 (a reload that arrives during startup pauses the frontends for good: same window, opposite outcome; not addressed here). The reload this PR schedules comes after the last init step.
Fixes: https://tracker.ceph.com/issues/81911
Checklist