Skip to content

rgw/multisite: defer datalog entries a stale period cannot resolve - #72777

Open
lumir-sliva wants to merge 2 commits into
ceph:mainfrom
lumir-sliva:rgw-data-sync-stale-master-lookup
Open

lumir-sliva wants to merge 2 commits into
ceph:mainfrom
lumir-sliva:rgw-data-sync-stale-master-lookup

Conversation

@lumir-sliva

Copy link
Copy Markdown
Contributor

Summary

A zone that comes back after the metadata master moved can lose, for good, the objects written to buckets that were created on the new master while it was away. No error, nothing in sync error list, and sync status says caught up.

Problem

The returning zone starts on its local period, in which it is still the metadata master itself. The new master's period push only lands later, because the pusher backed off while the zone was unreachable (rgw_period_push_interval_max, 30 s by default). Until then:

  • data sync processes the new master's datalog, finds no local instance for the new bucket, and RGWSyncGetBucketInfoCR fetches it from get_master_conn(), i.e. from itself. Its own access log shows the GET /admin/metadata/bucket.instance/... answered 404.
  • RGWMetaSyncSingleEntryCR takes the 404 as "deleted", RGWGetBucketPeersCR tolerates the -ENOENT, the pipe set comes back empty and RGWRunBucketSourcesSyncCR completes with r=0.
  • the shard marker moves past the entry, nothing is written to the error repo, and nothing ever revisits it.

The same happens without a restart when a link cut heals after the master moved.

Fix

Before giving a bucket up on that 404, read the realm from the zone that logged the entry (GET /admin/realm over the data sync source connection) and compare realm epochs:

  • source on a newer realm epoch than our current period: the 404 came from a master the realm no longer has. Return -ESTALE; RGWDataSyncSingleEntryCR writes the entry to the error repo and completes it, so it's retried on the error repo's backoff until the period push lands and the realm reload restarts sync.
  • equal epochs: the 404 is authoritative and the bucket is skipped as before, so a bucket deleted on the master still converges.
  • realm read fails: return that error, not -ENOENT.

The instance is never fetched from the source zone, which would resurrect buckets deleted on the master and not yet on the source.

The parked entry completes instead of failing because a failed entry fails the whole data sync shard: the restarted shard retries its entire error repo at once, and with writes still arriving on the new master that repeats on every poll. Out-of-band notifications carry no timestamp and can't be parked; they complete as well, since their datalog entry follows and is parked then.

In full sync the deferral only gets parked once full sync obligations carry a timestamp, which they currently never do: #72776 (https://tracker.ceph.com/issues/81830). Without it the full sync case behaves as it does on main.

Test

Two zones from test-rgw-multisite.sh on one box: zone 1 (master) stopped, zone 2 promoted, a bucket with 5 objects created on zone 2, zone 1 restarted. Zone 2's push is delayed with rgw_period_push_interval{,_max}=120 so that zone 1's data sync always gets to the entry first.

main with the fix
bucket created during the outage lost in 5 of 5 runs 0 lost in 2 runs
same, client writing to the bucket and to 10 new ones during the 232 s window, rgw_data_notify_interval_msec=200 105 of 105 objects, 10 of 10 buckets, 0 shard restarts, 0 entry errors

Earlier iterations of the same approach lost nothing in another 11 runs. While the zone is stale, each entry touching an unresolvable bucket costs two extra requests (the self-lookup and the realm GET), 185 over the 232 s window above; they stop with the push.

The second commit adds test_bucket_created_during_master_outage, which raises the push interval on the secondary's cluster with config set to hit the window every time. On main it fails at zone_bucket_checkpoint after 526 s; with the fix it passes in 352 s. test_multi_period_incremental_sync passes with the fix (with #72671 on top for the unrelated https://tracker.ceph.com/issues/81758).

Not exercised in a run: the equal-epoch path for a bucket really deleted on the master. Deleting a bucket through S3 keeps its bucket.instance on the master, so in my tries the master never answered 404; that path is the unchanged one.

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

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)

When data sync meets a datalog entry for a bucket it has no instance
for, RGWSyncGetBucketInfoCR fetches the instance from the metadata
master and RGWMetaSyncSingleEntryCR treats a 404 as "deleted". Which
zone is the master comes from the local period, and a zone that missed
a period push is on an old one. A zone that was down while the master
moved comes back on its old period, in which it is still the master
itself, and answers its own lookup with 404 for every bucket created on
the new master while it was away. The bucket peers come back empty, the
entry completes as if synced, the shard marker moves past it, nothing is
written to the error repo and the objects never arrive. The same happens
without a restart when a link cut heals after the master moved, and to a
secondary whose period is stale and whose old master has not synced the
bucket yet.

Before giving a bucket up on a 404, read the realm from the zone that
logged the entry (GET /admin/realm over the data sync source connection)
and compare realm epochs. If the source is on a newer realm epoch than
the local current period, the 404 came from a master the realm no longer
has, so return -ESTALE. If the realm cannot be read, return that error
rather than -ENOENT. On equal epochs the 404 is authoritative and the
bucket is skipped as before, so a bucket deleted on the master still
converges. The bucket instance is never fetched from the source zone,
which would resurrect buckets that were deleted on the master and not
yet on the source.

RGWDataSyncSingleEntryCR writes a deferred entry to the error repo as
for any failure, but then completes successfully, so the entry is
retried on the error repo's own backoff until the period push arrives
and the realm reload restarts sync. Failing it would fail the whole
shard: the restarted shard retries its entire error repo at once, and
with writes arriving on the new master it does so again on every poll.
An out-of-band notification has no timestamp and can't be parked; it
completes too, since its datalog entry follows and is parked then. In
full sync, RGWDataFullSyncSingleEntryCR no longer gives a bucket up when
its first shard is deferred, and goes on to the remaining shards.

RGWSyncGetBucketInfoCR has no sync context of its own, so the source
connection is passed in by its callers: RGWSyncBucketCR from sc->conn,
RGWGetBucketPeersCR from its source zone, and through
RGWSyncGetBucketSyncPolicyHandlerCR. Without a source zone (bucket sync
run without --source-zone) nothing changes. The deferral is logged as a
warning each time the entry is tried, since a zone that never receives
the new period keeps retrying until its period is updated. It is not
logged as an error by the callers and stays out of 'sync error list',
like -EBUSY and -EAGAIN.

Fixes: https://tracker.ceph.com/issues/81761
Signed-off-by: Lumir Sliva <[email protected]>
Stop the master zone, promote a secondary, create a bucket with an
object there, then start the old master and check that the object
reaches it. The push of the new period to the old master fails while it
is down and is retried after rgw_period_push_interval; raise that on the
secondary's cluster so the old master runs data sync on its old period,
in which it is still the master, before the new period reaches it.
Without the fix the old master looks the bucket instance up on itself,
takes the 404 for a deleted bucket, drops the datalog entry and the
bucket sync checkpoint times out.

Fixes: https://tracker.ceph.com/issues/81761
Signed-off-by: Lumir Sliva <[email protected]>
@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.

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.

1 participant