Repository navigation
rgw/multisite: fix metadata sync of past periods - #72670
lumir-sliva wants to merge 5 commits into
Conversation
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
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 |
RGWMetaSyncShardCR::incremental_sync() leaves a past period when period_marker <= mdlog_marker. mdlog_marker starts at our sync position, but RGWCloneMetaLogCoroutine then clones the remote mdlog shard up to its tip (it loops while the listing is truncated) and moves mdlog_marker there, while each pass of the loop reads and applies at most INCREMENTAL_MAX_ENTRIES (100) of the cloned entries. So when a zone is more than 100 entries behind on a shard at the end of a period (a zone that was down while the master moved), the first pass applies 100 entries, the clone has already moved mdlog_marker past period_marker, and the second pass declares the period done: the rest of that period's entries on the shard are never applied. Users, buckets and other metadata created in that period are missing on the zone, with no error, and sync status reports it caught up. Compare period_marker with max_marker, the position we've read up to. Both start at the sync position, so a period that was already finished still ends on the first pass; reaching period_marker while applying entries ends it as before. Fixes: https://tracker.ceph.com/issues/81759 Signed-off-by: Lumir Sliva <[email protected]>
Stop the third zone, move the metadata master to the second zone, create 150 buckets whose mdlog entries all hash to the same shard, move the master back and start the third zone. Metadata sync reads a shard in batches of 100 entries, so the third zone has to walk more than one batch of the past period on that shard. It must end up with every bucket. Fixes: https://tracker.ceph.com/issues/81759 Signed-off-by: Lumir Sliva <[email protected]>
…eway RGWMetaSyncCR walks the period history one period at a time and only advances once every shard of the past period has completed in this process. RGWMetaSyncShardCR returns -EBUSY right away when this gateway isn't the highest bidder for the shard, in both full_sync() and incremental_sync(), before it gets to the "finished syncing current period" check, and RGWBackoffControlCR retries that forever. With more than one gateway running the sync thread, a gateway only leaves a past period if it wins the bid for every shard that period has, so after a master change and failback, metadata sync on the secondary stays on the old period for good while "sync status" reports it caught up. When a gateway loses the bid on a past-period shard, or wins it but can't take the lease because another gateway holds it (that one keeps the lease while it syncs the shard in a later period), read the shard marker from rados and treat the shard as complete if its owner already synced up to the period marker, or moved on to a later period. For that to work the owner has to leave a trace. The marker tracker only writes the shard marker when an entry gets applied, so a shard that finishes the period without applying anything (the log holds nothing past our position, e.g. the entries were trimmed after this zone wrote them as master) keeps a marker from the previous realm epoch. Have the owner write the shard marker with the period's realm epoch and the period marker once it is done with the period, while it still holds the lease. If the lease ran out while the last entries were draining, retry the period instead. The write starts from the stored marker, keeping the tracker's position and timestamp, and is skipped when the stored marker already records the period as done or is on a later realm epoch, so it never moves a marker back. A gateway can also take the lease with a stale marker: it lost the bid or the lease, another gateway finished the period and moved the shard on, and then the bid came back to it. It checks the stored marker right after taking the lease and finishes the shard without replaying the period if it's already done. Every gateway now advances through past periods on its own, and each writes the metadata sync info when it does. That write isn't versioned, so a gateway that finishes a period later than another can store an earlier, still valid period over a later one. It rewrites it once it catches up, but a gateway that restarts in between re-walks from the earlier period. Fixes: https://tracker.ceph.com/issues/81762 Signed-off-by: Lumir Sliva <[email protected]>
0c3eb9c to
9d8b4e6
Compare
|
@cbodley Rebased, please set the flag again. Thx |
|
When this is ready for a review, please add the needs-review label, @lumir-sliva . |
I'm not a member of the org I cant set it :( its ready |
RGWMetaSyncShardCR::incremental_sync() ends a past period once max_marker, the position read from the cloned mdlog, reaches period_marker. That never happens when the period's entries are gone: a zone that was the master of a period doesn't sync it while it is master, its peers sync it, and mdlog trimming removes the entries. When the zone later becomes a secondary, it has to walk that period with an empty sync marker. The clone still moves mdlog_marker to the shard's last marker (the log header keeps it), but reading from max_marker returns no entries, so max_marker never moves and the shard clones and reads the same empty log forever. Metadata sync of the whole zone stays on the old period and nothing created later reaches it. Also end the period when the clone has reached period_marker and the last read found nothing more (truncated is false): everything that is left of the period has been read. On the first pass mdlog_marker and max_marker are both the sync position, so this can't end a period earlier than before; with entries still to read, truncated stays true until the last batch, which ends the period at period_marker as before. Seen on a two-zone lab after failover, failback, failover: the zone that was master in the middle period stayed on it for good, with 0 entries in the period's log on both zones; the owning gateway's sync trace showed the clone at period_marker, 0 entries read and an empty max_marker on every pass. Fixes: https://tracker.ceph.com/issues/81759 Signed-off-by: Lumir Sliva <[email protected]>
zone 2 is master of period 2 and doesn't sync it, the other zones do, every zone trims the mdlog, then zone 1 becomes master again. zone 2 has to sync period 2 from a log without entries and must still reach the current period and see the buckets created in periods 2 and 3. Fixes: https://tracker.ceph.com/issues/81759 Signed-off-by: Lumir Sliva <[email protected]>
|
Pushed two commits on top:
The Q fix as first posted can hang metadata sync for good. Details below: how we ran into it, the cause, the fix and what was tested. How we found itOur lab is two sites with two realms, each realm's master zone in one site and its secondary in the other, 4 gateways per zone, tentacle 20.2.4 + #71707 + this PR + #72669 + #72776/#72777/#72778. We were running failover drills on realm A:
Step 3 was meant to check the new A user and a bucket created on the new master never showed up on that zone; we waited 65 min and restarted all 4 gateways. Without #72778 this would have stayed hidden: the old CauseEpoch 4 is the period in which that zone was the master. A master doesn't sync its own period; the other zone did, and mdlog trimming then removed the entries. The sync marker is cleared on the realm epoch change, the clone moves FixThe period now also ends when the clone has reached Testing
Lab, tentacle build with the fix, 4 gateways per zone:
Not re-run on this head yet: Happy to squash these into the Q fix and the test commit if you'd rather keep the history flat. |
|
Ran what my last comment listed as not re-run, on the head (401f96f), main 04ba07e + this PR, 3 zones:
The backlog failure isn't in this PR. One of a3's two gateways never reloads after the zone restarts:
Startup loads the period in So the backlog test here only claims 1 gateway per zone, where it passes. Happy to make it skip with more than one gateway per zone until the reload fix lands, if you'd rather not have it fail locally in that setup. |
Two bugs in how a secondary catches up on past periods after a master change. Both leave metadata missing on the zone while
sync statusreports it caught up.More than 100 entries behind on a shard (first commit).
RGWMetaSyncShardCR::incremental_sync()leaves a past period whenperiod_marker <= mdlog_marker. ButRGWCloneMetaLogCoroutineclones the remote shard up to its tip and movesmdlog_markerthere, while each pass applies at most 100 entries. So on the second pass the period ends and everything after the first batch is never applied. Compare againstmax_marker, the position actually read, instead. This dates back to 574ff5f (2017).The second commit adds
test_multi_period_incremental_sync_backlog: the third zone is down while the master moves, 150 buckets are created whose mdlog entries all hash to the same shard, and after the master moves back the third zone must have all of them. It works with the default shard count. Without the fix it fails (3 of 3; 50 of 150 buckets missing), with it it passes (3 of 3). It takes about 8 minutes, most of it the two master changes and the checkpoints.More than one gateway running the sync thread (third commit).
RGWMetaSyncCRadvances to the next period only once every shard of the past period completed in the same process.RGWMetaSyncShardCRreturns -EBUSY for a shard this gateway doesn't hold the bid for (#45958), before the "finished syncing current period" check, andRGWBackoffControlCRretries that forever. So a gateway only gets out if it wins the bid on every shard, and with more than one sync gateway the secondary stays on the old period for good.The fix:
This end-of-period write is why the first commit comes first: it is based on the position actually read.
Every gateway now advances through past periods on its own, and each writes the unversioned sync info, so one that finishes a period later can store an earlier, still valid period over a later one until it catches up. It's in the commit message; happy to switch that write to a version-checked one if you'd rather. The fix only fully applies once every gateway running the sync thread in the zone has it.
Tested with
test_multi_period_incremental_sync(3 zones, 2 gateways per zone), which reproduces the multi-gateway stall once https://tracker.ceph.com/issues/80439 (#71707), https://tracker.ceph.com/issues/81760 and https://tracker.ceph.com/issues/81758 are fixed:rgw_rest_conn_connect_to_resolved_ips=falseto avoid https://tracker.ceph.com/issues/81756): 5 of 5An earlier version of the third commit also passed 3 of 3 failover/failback runs on two tentacle 20.2.4 clusters with 4 sync gateways per zone.
Teuthology runs one gateway per zone, so the multisite suite can't hit the second bug; the existing test does with
gateways_per_zone = 2in the test config.Fixes: https://tracker.ceph.com/issues/81759
Fixes: https://tracker.ceph.com/issues/81762
Backport: squid, tentacle.
Checklist