Project

General

Profile

Actions

Bug #80389

closed
OO SP

qa/rgw/multisite - multiple testcase failures: ObjectCache::put() obj_version guard can leave the cache ahead of RADOS on secondary zones, stalling metadata sync for rgw_cache_expiry_interval

Bug #80389: qa/rgw/multisite - multiple testcase failures: ObjectCache::put() obj_version guard can leave the cache ahead of RADOS on secondary zones, stalling metadata sync for rgw_cache_expiry_interval

Added by Oguzhan Ozmen 3 months ago. Updated 2 months ago.

Status:
Backporting
Priority:
Urgent
Target version:
-
Due date:
% Done:

0%

Source:
Community (dev)
Backport:
squid tentacle umbrella
Regression:
Yes
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-3609-ga9e3451f58
Released In:
Upkeep Timestamp:
2026-09-25T00:45:48+00:00

Description

QA Test Failures

See https://pulpito.ceph.com/bcs-ceph-2026-09-08_17:28:33-rgw-wip-oozmen-75571-distro-default-trial/544349/ as an example.

Failed Tests:
- 2026-09-08T19:10:30.137 INFO:tasks.rgw_multisite_tests:FAIL: rgw_multi.tests.test_copy_object_replacing_tagging
- 2026-09-08T19:10:30.135 INFO:tasks.rgw_multisite_tests:FAIL: rgw_multi.tests.test_copy_object_same_bucket
- 2026-09-08T19:10:30.134 INFO:tasks.rgw_multisite_tests:ERROR: rgw_multi.tests.test_account_metadata_sync

Summary

The obj_version guard added to ObjectCache::put() in PR #69748 - rgw: skip writing ObjectCache when incoming obj_version is stale (fix for #77554) assumes that obj_version.ver increases monotonically per tag. That assumption does not seem to hold on a multisite SECONDARY zone, where the same metadata object is written by two uncoordinated version sources: local forwarded ops use cls_version_inc, while metadata sync uses cls_version_set with the master's version .

When a legitimate, already-committed write lowers ver, the new guard refuses to record it, leaving the cache advertising a version that no longer exists in RADOS.

Every subsequent read-modify-write on that object (on a SECONDARY zone) then fails -ECANCELED until rgw_cache_expiry_interval (default 900s). This wedges the metadata sync shard and returns HTTP 409 ConcurrentModification to clients (again when the SECONDARY zone is accessed actively).

Having said this, it's not client-driven. Metadata sync races itself, so a PASSIVE secondary is exposed too I believe; it'd be visible as large metadata sync lags.

Impact

  • Metadata sync marker for the affected shard cannot advance for up to 900s (by default); hence, as a silent failure, we'd see large metadata sync lag.
  • If secondary site is actively accessed by an S3 client -> 409 ConcurrentModification on IAM updates; 500 UnknownError on bucket-metadata ops. Retries cannot help — the
    reload re-reads the same stale cache.
  • Reads may return content stale relative to RADOS, since a higher ver does not imply newer content on a secondary.
  • rgw_cache_expiry_interval is not a usable workaround: expiry is captured once and the option has no runtime flag, so lowering it needs an RGW restart.
  • Good news -> No data loss I believe: RADOS holds a valid state, sync never skips the failing entry.

Evidence

Upstream rgw/multisite teuthology run (tasks/test_multi, two zones): test_account_metadata_sync errored with ConcurrentModification, two following tests failed on zonegroup_meta_checkpoint.

    18:22:27.098  iam:detach_group_policy    cache put: ...groups+info.305c4efe...  -> RADOS ver 5, cache ver 5
    18:22:27.121  rgw async rados processor: cache put: ... skipping stale ver=4 (cached ver=5)
    18:22:27.121  rgw async rados processor: distributing notification ... [op: 0 (UPDATE_OBJ)]

From there the sync worker retried the remove for ~901s without ever making progress. Everyx read was a cache hit, so nothing ever refreshed the cached version. It recovered only when the cache entry expired:

    18:37:28.513  cache get: ... : expiry miss
    18:37:28.518  RGW-SYNC:meta:shard[1]:entry[group:305c4efe...]: success

Potential fix

On conflict, invalidate the entry instead of keeping the newer one. Preserves the #77554 guarantee and would behave correctly for both the local put and the notify path. Cost is one extra RADOS read per genuine conflict. Alternatively, let the authoritative post-write put bypass the guard and carry a "FORCE" bit in the UPDATE_OBJ notify.


Related issues 4 (2 open — 2 closed)

Related to rgw - Bug #77554: rgw/Multisite: race condition in ObjectCache::put() allows stale cache notify to overwrite newer entry, causing multisite sync to persist wrong bucket metadataBackportingSaravanan Palanisamy

Actions
Copied to rgw - Backport #80864: squid: qa/rgw/multisite - multiple testcase failures: ObjectCache::put() obj_version guard can leave the cache ahead of RADOS on secondary zones, stalling metadata sync for rgw_cache_expiry_intervalResolvedSaravanan Palanisamy

Actions
Copied to rgw - Backport #80865: tentacle: qa/rgw/multisite - multiple testcase failures: ObjectCache::put() obj_version guard can leave the cache ahead of RADOS on secondary zones, stalling metadata sync for rgw_cache_expiry_intervalFix Under ReviewAdam Emerson

Actions
Copied to rgw - Backport #80866: umbrella: qa/rgw/multisite - multiple testcase failures: ObjectCache::put() obj_version guard can leave the cache ahead of RADOS on secondary zones, stalling metadata sync for rgw_cache_expiry_intervalNewSaravanan Palanisamy

Actions

OO Updated by Oguzhan Ozmen 3 months ago Actions #1

  • Related to Bug #77554: rgw/Multisite: race condition in ObjectCache::put() allows stale cache notify to overwrite newer entry, causing multisite sync to persist wrong bucket metadata added

JI Updated by J. Eric Ivancich 3 months ago Actions #2

@Oguzhan Ozmen Would you like to assign this tracker to yourself?

CB Updated by Casey Bodley 3 months ago Actions #3

thanks @Oguzhan Ozmen,

i see that the tentacle backport of https://tracker.ceph.com/issues/79147 already merged for the upcoming point release. i commented on the squid https://github.com/ceph/ceph/pull/71059 and umbrella https://github.com/ceph/ceph/pull/71061 backport prs to prevent them from merging in the meantime

That assumption does not seem to hold on a multisite SECONDARY zone, where the same metadata object is written by two uncoordinated version sources: local forwarded ops use cls_version_inc, while metadata sync uses cls_version_set with the master's version.

can you clarify which code paths lead to the use of cls_version_set? does that apply to all RGWMetadataHandler types, or just some?

i always found it suspicious that these local cls version numbers were visible to the meta sync protocol at all. i have a feeling that we should ignore them entirely, and rely on cls_version_inc exclusively for metadata sync

SP Updated by Saravanan Palanisamy 3 months ago · Edited Actions #4

@Oguzhan Ozmen

On conflict, invalidate the entry instead of keeping the newer one. Preserves the #77554 guarantee and would behave correctly for both the local put and the notify path. Cost is one extra RADOS read per genuine conflict

invalidating the cache entry will not solve the race condition. It just shift the race condition to different window altogether. It will just fix this symptom. But does not solve the problem.

SP Updated by Saravanan Palanisamy 3 months ago Actions #5

@Oguzhan Ozmen @Casey Bodley

Metadata sync races itself, so a PASSIVE secondary is exposed too I believe; it'd be visible as large metadata sync lags.

I believe this can be related to this:
https://tracker.ceph.com/issues/79311

OO Updated by Oguzhan Ozmen 3 months ago Actions #6

@Casey Bodley

can you clarify which code paths lead to the use of cls_version_set? does that apply to all RGWMetadataHandler types, or just some?

Not per-handler. RGWMetadataManager::put() decodes the envelope's version into objv_tracker.write_version for every metadata type, before find_handler()...

RGWObjVersionTracker::prepare_op_for_write then chooses purely on that:

    prepare_op_for_write()
        write_version.ver != 0  =>  cls_version_set()   // master's version   (B)
        write_version.ver == 0  =>  cls_version_inc()   // local +1           (A)

    (A) local apply of a master-forwarded op. Doesn't go through RGWMetadataManager,
        so write_version is never populated and it increments whatever is on disk.
    (B) metadata sync worker. Goes through RGWMetadataManager::put(), so write_version
        carries the master's number and persists that value.

So the question is which handlers forward the same tracker object all the way down to the RADOS write call. Most of metadata types directly: user, bucket (entrypoint), account, ...

On the failing test test_account_metadata_sync: the divergence was created by the local apply of DetachGroupPolicy (inc to ver 5) racing sync's cls_version_set(4). Then tripped by DeleteGroup, which read ver 5 from cache and got -ECANCELED@ (409).

@[email protected]

I believe this can be related to this: https://tracker.ceph.com/issues/79311

Yes, definitely. https://github.com/ceph/ceph/pull/71058 is the right direction and closes some cases we hit ... it narrows but not fully eliminating: full sync deliberately keeps APPLY_ALWAYS ("forces a diverged zone back into line"), and radosgw-admin metadata put and the admin REST PUT (both default to it so a legitimately-lower "ver" can still be committed.

@J. Eric Ivancich

@Oguzhan Ozmen Would you like to assign this tracker to yourself?

I think Saravanan can take this one as he's been working issues around this subject.

OO Updated by Oguzhan Ozmen 3 months ago 1Actions #7

  • Assignee set to Saravanan Palanisamy

Taking the liberty to assign the issue to Saravan.

CB Updated by Casey Bodley 3 months ago Actions #8

Oguzhan Ozmen wrote in #note-6:

Not per-handler. RGWMetadataManager::put() decodes the envelope's version into objv_tracker.write_version for every metadata type, before find_handler()...

thanks. can we remove that JSONDecoder::decode_json("ver", *objv, &parser); line and leave write_version alone?

SP Updated by Saravanan Palanisamy 3 months ago Actions #9

Oguzhan Ozmen wrote in #note-7:

Taking the liberty to assign the issue to Saravan.

A few thoughts on this:

1. Lower rgw_cache_expiry_interval

Lowering the interval would make the test pass. Cache is eventually consistent by design, and expiry is the intended backstop.

Here, the 300s checkpoint budget (60 × 5s) means any expiry below that should clear the failure.

The same cache staleness condition can be reproduced even when notifiers fails to distribute fails.

To note: the expiry interval is irrelevant to #77554 failure. The stale cache value would already have been read and applied at the secondary. There is no retry mechanism from secondary to master, which could prevent inconsistent metadata sync between master and secondary here.

2. Plumb refresh_version through retry loops

refresh_version already exists end-to-end on the bucket path:

  • retry_raced_bucket_write -> try_refresh_bucket_info (rgw_rados.cc:10484-10498)
  • It carries the version that just failed and asks the cache to reload the value from OSD.

3. Source-aware cache guard

Make ObjectCache aware of where the update came from (remote/local) and add an untrusted flag to the cache entry.

  • Local
    • put(): cache guard is enforced.
    • Cache entry remains trusted.
  • Remote
    • put(): on conflict, mark the entry as untrusted and clear the content.
  • get(): Local and Remote: if the cache entry is untrusted, return ENOENT.
  • The caller then reads from RADOS and updates the cache entry with the trusted flag.
  • Subsequent get() calls are normal cache hits with the correct value.

4. Increment on secondary

Pros:
  • Version becomes monotonic.
  • Fixes #80389 at the root.
  • #77554 's guard becomes valid again.
Cons:
  • Master and secondary versions numerically diverge.
  • Master and secondary versions are currently not compared anywhere.
  • PR #71058 / #79311 currently use check_versions / APPLY_UPDATES with ondisk.ver < incoming.ver to determine race conditions between two sync updates. This would need an alternative approach.

Alternate option: Vector clock

Another option I considered is using a vector clock. The failure is essentially a two-writer, one-counter problem, and in multisite it can become a multiple-writer, one-counter problem.

A version vector such as {Master: n, Secondary: n} would correctly capture the versions from each writer. For concurrent versions, e.g. {Master: 5, Secondary: 0} vs {Master: 4, Secondary: 1}, we could define Master as the tie-breaker.

However, this would require significant changes/rewrite across the versioning and replication paths, so I don't think it's a practical fix now.

OO Updated by Oguzhan Ozmen 3 months ago Actions #10

@Casey Bodley

can we remove that JSONDecoder::decode_json("ver", *objv, &parser); line and leave write_version alone?

@[email protected]

Increment on secondary

Yes, I also think this is the solution for this issue: simple but elegant.
Incoming source version from master can perhaps be decoded into a separate variable if it's needed for any remote ordering but yes it must not be used as the destination's (secondary zone's) local RADOS version.
This will fix the root cause of this issue by restoring one monotonic & local-zone only version sequence.

Just to emphasize as we touched base on it in earlier notes: this does not solve the out-of-order content problem in #79311 (pending PR: rgw/multisite: rgw meta sync version check #71058 ); that one still needs a separate remote ordering solution.

With this proposed fix,
  • we can revive the backport of #77554
  • and also backport this fix along with it

SP Updated by Saravanan Palanisamy 3 months ago Actions #11

  • Pull request ID set to 71779

SP Updated by Saravanan Palanisamy 3 months ago Actions #12

Oguzhan Ozmen wrote in #note-10:

Just to emphasize as we touched base on it in earlier notes: this does not solve the out-of-order content problem in #79311 (pending PR: rgw/multisite: rgw meta sync version check #71058 ); that one still needs a separate remote ordering solution.

I would look into how such syncs are serialized in data sync.

JI Updated by J. Eric Ivancich 2 months ago Actions #13

  • Status changed from New to Resolved

UB Updated by Upkeep Bot 2 months ago Actions #14

  • Merge Commit set to a9e3451f5882d4d3f2aa6373297235c6c9f96d83
  • Fixed In set to v21.3.0-3609-ga9e3451f58
  • Upkeep Timestamp set to 2026-09-24T14:07:48+00:00

SP Updated by Saravanan Palanisamy 2 months ago Actions #15

  • Backport set to squid, tentacle

SP Updated by Saravanan Palanisamy 2 months ago Actions #16

  • Backport changed from squid, tentacle to squid

SP Updated by Saravanan Palanisamy 2 months ago Actions #17

  • Backport changed from squid to squid tentacle umbrella

SP Updated by Saravanan Palanisamy 2 months ago Actions #18

  • Source set to Community (dev)

SP Updated by Saravanan Palanisamy 2 months ago 1Actions #19

@Oguzhan Ozmen
The fix PR #71779 has been merged. The issue was auto resolved before backport field was set. Can you change the status to "Pending Backport", so redmine-upkeep can create backport tracker?

OO Updated by Oguzhan Ozmen 2 months ago Actions #20

  • Status changed from Resolved to Pending Backport

UB Updated by Upkeep Bot 2 months ago Actions #21

  • Copied to Backport #80864: squid: qa/rgw/multisite - multiple testcase failures: ObjectCache::put() obj_version guard can leave the cache ahead of RADOS on secondary zones, stalling metadata sync for rgw_cache_expiry_interval added

UB Updated by Upkeep Bot 2 months ago Actions #22

  • Copied to Backport #80865: tentacle: qa/rgw/multisite - multiple testcase failures: ObjectCache::put() obj_version guard can leave the cache ahead of RADOS on secondary zones, stalling metadata sync for rgw_cache_expiry_interval added

UB Updated by Upkeep Bot 2 months ago Actions #23

  • Copied to Backport #80866: umbrella: qa/rgw/multisite - multiple testcase failures: ObjectCache::put() obj_version guard can leave the cache ahead of RADOS on secondary zones, stalling metadata sync for rgw_cache_expiry_interval added

UB Updated by Upkeep Bot 2 months ago Actions #24

  • Status changed from Pending Backport to Backporting
  • Upkeep Timestamp changed from 2026-09-24T14:07:48+00:00 to 2026-09-25T00:45:48+00:00
Actions

Also available in: PDF Atom