Skip to content

rgw: preserve head mtime in olh_cancel_modification() - #72605

Merged
BBoozmen merged 7 commits into
ceph:mainfrom
BBoozmen:wip-oozmen-81668-olh-cancel-mtime
Oct 29, 2026
Merged

BBoozmen merged 7 commits into
ceph:mainfrom
BBoozmen:wip-oozmen-81668-olh-cancel-mtime

Conversation

@BBoozmen

Copy link
Copy Markdown
Contributor

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

The existing testcase "TESTCASE 'verify that original null object version is intact after failed olh upgrade'" already shows/reproduces the issue; w/o the fix, the new assert added in this PR triggers.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@BBoozmen BBoozmen self-assigned this Oct 12, 2026
@BBoozmen
BBoozmen requested a review from a team as a code owner October 12, 2026 18:21
@smanjara

Copy link
Copy Markdown
Contributor

what if a new PUT operation overwrites the null-version object in between, but the rollback moves the head mtime backward. in case of multisite, a zone that already has the previous null version treats the head as unchanged and could skip the update?

@BBoozmen

Copy link
Copy Markdown
Contributor Author

what if a new PUT operation overwrites the null-version object in between, but the rollback moves the head mtime backward. in case of multisite, a zone that already has the previous null version treats the head as unchanged and could skip the update?

Thank you @smanjara , great catch! Yes, an overwrite of the null version keeps the OLH attrs (cls_rgw_remove_obj() keeps the RGW_ATTR_OLH_PREFIX attrs), including the OLH tag, so the olh tag guard alone doesn't detect it, and the rollback would stamp the old mtime onto the new data.

In the new evidence, added a test case to the same file to reproduce this exact same scenario: it holds/delays the rollback, then overwrites the null version in that window, and checks HEAD ?versionId=null and ListObjectVersions report the same LastModified. It fails consistently without the fix and passes with it.

The updated fix now:

  • pins the mtime only if the head's RGW_ATTR_ID_TAG is unchanged
  • if that check fails, re-reads the head and retries, pinning the head's current mtime. That's the overwrite's own mtime, which matches its bucket index entry.

FWIW, the race you describe here is already there in olh_init_modification_impl() & apply_olh_log(). In fact, the original fix here was adding the same logic to rollback. From reading the code, the same pattern exists in these 2 functions as well: both pin state.mtime guarded only by OLH attrs...with narrower windows I think. remove_olh_pending_entries() also rewrites the head without pinning the mtime. I can/will open a separate tracker for them to take a closer look later.

Below is some result for the new testcase (from a local copy of the test that logs both values instead of asserting): A is the op getting rolled back and B is the overlapping successful write.

  1. Previous revision of this PR (mtime pinned, no ID_TAG check). This is the race scenario you described: the rollback puts back the old null version's mtime, older than the overwrite.
  CHECK FAIL: HEAD ?versionId=null LastModified=23:59:09  ListObjectVersions LastModified=23:59:21  (races with an overwrite)

  23:59:09.287 req 107437… s3:put_obj http status=200                          <- null version "data"
  23:59:15.199 req 632079… s3:put_obj bucket_index_link_olh() returned -2       <- A: injected set_olh failure
  23:59:15.199 req 632079… s3:put_obj olh_cancel_modification: injecting delay of 20s
  23:59:21.505 req 541099… s3:put_obj http status=200                          <- B: overwrites the null version
  23:59:35.210 req 632079… s3:put_obj http status=404                          <- A: rollback pins the OLD mtime (23:59:09)
  1. Without any fix (before this PR): the rollback stamps "now", later than the overwrite but also diverges mtime from bucjet index entry causing the issue described in the tracker.
  CHECK FAIL: HEAD ?versionId=null LastModified=19:10:05  ListObjectVersions LastModified=19:09:51  (races with an overwrite)

  19:09:39.357 req 163685… s3:put_obj http status=200                          <- null version "data"
  19:09:45.280 req 170648… s3:put_obj bucket_index_link_olh() returned -2       <- A: injected set_olh failure
  19:09:45.280 req 170648… s3:put_obj olh_cancel_modification: injecting delay of 20s
  19:09:51.602 req 239621… s3:put_obj http status=200                          <- B: overwrites the null version
  19:10:05.292 req 170648… s3:put_obj http status=404                          <- A: rollback stamps the head "now"
  1. With the latest fix/evidence:
  CHECK PASS: HEAD ?versionId=null LastModified=19:13:12  ListObjectVersions LastModified=19:13:12  (races with an overwrite)

  19:12:59.827 req 151448… s3:put_obj http status=200                          <- null version "data"
  19:13:05.791 req 384915… s3:put_obj bucket_index_link_olh() returned -2       <- A
  19:13:05.791 req 384915… s3:put_obj olh_cancel_modification: injecting delay of 20s
  19:13:12.162 req 394266… s3:put_obj http status=200                          <- B
  19:13:25.823 req 384915… s3:put_obj http status=404                          <- A: rollback keeps B's mtime

@BBoozmen
BBoozmen force-pushed the wip-oozmen-81668-olh-cancel-mtime branch from aabf654 to e56f204 Compare October 14, 2026 00:11
Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
Extend the already existing 'original null object version is intact after failed
olh upgrade' test case.

After the injected set_olh() failure is rolled back, HEAD ?versionId=null must
report the same LastModified as the null version's ListObjectVersions entry.

That's, HEAD shouldn't report the failed request's time.

Signed-off-by: Oguzhan Ozmen <[email protected]>
Add a delay injection point in olh_cancel_modification() so that we can delay
the rollback of the pending OLH xattr.

This can be used to test scenarios like  a concurrent overwrite of the head
object in that window.

Signed-off-by: Oguzhan Ozmen <[email protected]>
…h an overwrite

Hold the rollback of a failed olh upgrade with the
"delay_olh_cancel_modification" delay point and overwrite the null version
in the meantime. HEAD ?versionId=null must still report the same
LastModified as the null version's ListObjectVersions entry. The rollback must not
leave its pending OLH xattr behind either.

Signed-off-by: Oguzhan Ozmen <[email protected]>
When set_olh() or unlink_obj_instance() fails to update the bucket index, it
calls olh_cancel_modification() to roll back the pending OLH xattr. The
rollback issues an rmxattr write on the head object without setting an explicit
mtime, so RADOS stamped the head with the current time (i.e., now()).

This fix preserves the head object's mtime on the rollback write. This fix
mirrors what olh_init_modification_impl() and apply_olh_log() already do: pin
the mtime when they touch the head.

The rollback pins the mtime only if the head's RGW_ATTR_ID_TAG is unchanged.
The OLH tag guard alone doesn't catch a concurrent overwrite of the null
version, because the overwrite keeps the OLH attrs. If the ID_TAG check
fails, we'll re-read the head and retry, pinning its current mtime, which will
match the overwrite's bucket index entry. This is best effort: after a few retries,
or if the OLH tag changed, the rollback leaves the head alone. A leftover
pending xattr is then removed by the existing timeout cleanup.

To note: this issue was exposed in LC transitioning. When the head object was colocated
with a null version's data, the head's mtime is the null version's mtime. After
such a rollback, it no longer matched the mtime recorded in the bucket index
entry. While head object mtime reported the failed request's mtime, ListObjectVersions
reported the original time, and transition_obj()'s read_mtime check returns
-ECANCELED on every lifecycle pass, so the null version can never be transitioned.

Fixes: https://tracker.ceph.com/issues/81668
Signed-off-by: Oguzhan Ozmen <[email protected]>
…emoved

Leave the pending OLH xattr of a failed olh upgrade on the head, similar to a
crash before the rollback, by also skipping olh_cancel_modification() with
rgw_debug_inject_olh_cancel_modification_err.

Also, lower rgw_olh_pending_timeout_sec so that the next read of the key removes the
timed out entry in follow_olh().

HEAD ?versionId=null must still report the same LastModified as the null
version's ListObjectVersions entry.

Signed-off-by: Oguzhan Ozmen <[email protected]>
…e pending olh entry

Leave a timed out pending OLH xattr on the head, as in the previous test
case, and then delete the only linked version. clear_olh() removes the timed
out entry before removing the OLH head object, so the head object must be
gone afterwards.

This already passes; it covers the clear_olh() path of the next change.

Signed-off-by: Oguzhan Ozmen <[email protected]>
@BBoozmen
BBoozmen force-pushed the wip-oozmen-81668-olh-cancel-mtime branch from e56f204 to 3c09c18 Compare October 23, 2026 14:23
@BBoozmen
BBoozmen requested a review from smanjara October 23, 2026 14:24
Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
follow_olh() and clear_olh() remove pending OLH xattrs older than
rgw_olh_pending_timeout_sec through remove_olh_pending_entries().

Such an entry might be left behind if rgw crashes during set_olh() or
unlink_obj_instance(), or if olh_cancel_modification() fails to remove it.

The removal issues an rmxattr write on the head object without setting an
explicit mtime, so RADOS stamped the head with the current time. When the
head also holds the null version's data, its mtime no longer matched the
null version's bucket index entry.

Here, we pin the head's mtime on that write, guarded by RGW_ATTR_ID_TAG like the
rollback. The mtime and ID_TAG are read from the head here instead of taking
from the caller's state: i.e., in clear_olh(). That state may be cached. The read
only happens when timed out entries exist. If the head is overwritten between
the read and the write, the guard fails and the entries are left for the next
follow_olh() or clear_olh().

Fixes: https://tracker.ceph.com/issues/81668
Signed-off-by: Oguzhan Ozmen <[email protected]>
@BBoozmen
BBoozmen force-pushed the wip-oozmen-81668-olh-cancel-mtime branch from 3c09c18 to 8efa9e1 Compare October 27, 2026 13:58
@BBoozmen
BBoozmen requested a review from smanjara October 27, 2026 14:00
@BBoozmen BBoozmen added needs-qa wip-oozmen-testing for teuthology integration testing to be used via build-integration-branch.sh labels Oct 29, 2026
@BBoozmen

Copy link
Copy Markdown
Contributor Author

ceph-ci branch: https://github.com/ceph/ceph-ci/commits/wip-oozmen-testing-olh_cancel_modification-2026-10-29-0100/
qa run: https://pulpito.ceph.com/bcs-ceph-2026-10-29_12:44:42-rgw-wip-oozmen-testing-olh_cancel_modification-2026-10-29-0100-distro-default-trial/

Summary

90 suites in total: 89 PASSED, 1 FAILED

Failed Suite -> rgw/lua

This is a known issue: 2 of 10 lua tests failed, test_multi_delete_obj and test_access_log. Both show assert ['0'..'4'] == [] with UnixSocket: accept timed out. This is a known issue Bug #81310 rgw/lua: test_lua.py::test_access_log FAILED and fix is under review.

Not related to this PR.

testcases added in this PR to qa/workunits/rgw/test_rgw_versioning.py

Every rgw/verify job runs (24 of them) it and all passed. Each ran

  • the new delay case (rgw_inject_delay_pattern delay_olh_cancel_modification);
  • both rgw_debug_inject_olh_cancel_modification_err cases;
  • then logged Completed bucket versioning tests and echo OK., with 0 AssertionErrors.
  • The delay case asserts 'rollback was not held during the overwrite', so passing it also proves the new injection point in olh_cancel_modification() was actually hit.

E.g., job 691825

  2026-10-29T13:30:56.889 INFO:tasks.workunit.client.0.trial127.stderr:+ /home/ubuntu/cephtest/clone.client.0/qa/workunits/rgw/bin/python3 /home/ubuntu/cephtest/clone.client.0/qa/workunits/rgw/test_rgw_versioning.py
  ...
  2026-10-29T13:31:01.292 INFO:tasks.workunit.client.0.trial127.stderr:ceph config set client rgw_debug_inject_set_olh_err 2
  2026-10-29T13:31:01.516 INFO:tasks.workunit.client.0.trial127.stderr:ceph config set client rgw_inject_delay_sec 30
  2026-10-29T13:31:01.742 INFO:tasks.workunit.client.0.trial127.stderr:ceph config set client rgw_inject_delay_pattern delay_olh_cancel_modification
  2026-10-29T13:31:11.966 INFO:tasks.workunit.client.0.trial127.stderr:ceph config rm client rgw_debug_inject_set_olh_err
  2026-10-29T13:31:37.013 INFO:tasks.workunit.client.0.trial127.stderr:ceph config rm client rgw_debug_inject_set_olh_err
  2026-10-29T13:31:37.237 INFO:tasks.workunit.client.0.trial127.stderr:ceph config rm client rgw_inject_delay_sec
  2026-10-29T13:31:37.460 INFO:tasks.workunit.client.0.trial127.stderr:ceph config rm client rgw_inject_delay_pattern
  2026-10-29T13:31:42.811 INFO:tasks.workunit.client.0.trial127.stderr:ceph config set client rgw_debug_inject_set_olh_err 2
  2026-10-29T13:31:43.036 INFO:tasks.workunit.client.0.trial127.stderr:ceph config set client rgw_debug_inject_olh_cancel_modification_err true
  2026-10-29T13:31:43.262 INFO:tasks.workunit.client.0.trial127.stderr:ceph config set client rgw_olh_pending_timeout_sec 1
  2026-10-29T13:31:50.534 INFO:tasks.workunit.client.0.trial127.stderr:ceph config rm client rgw_debug_inject_set_olh_err
  2026-10-29T13:31:50.757 INFO:tasks.workunit.client.0.trial127.stderr:ceph config rm client rgw_debug_inject_olh_cancel_modification_err
  2026-10-29T13:31:50.985 INFO:tasks.workunit.client.0.trial127.stderr:ceph config rm client rgw_olh_pending_timeout_sec
  2026-10-29T13:31:56.333 INFO:tasks.workunit.client.0.trial127.stderr:ceph config set client rgw_debug_inject_set_olh_err 2
  2026-10-29T13:31:56.561 INFO:tasks.workunit.client.0.trial127.stderr:ceph config set client rgw_debug_inject_olh_cancel_modification_err true
  2026-10-29T13:31:56.785 INFO:tasks.workunit.client.0.trial127.stderr:ceph config set client rgw_olh_pending_timeout_sec 1
  2026-10-29T13:32:04.063 INFO:tasks.workunit.client.0.trial127.stderr:ceph config rm client rgw_debug_inject_set_olh_err
  2026-10-29T13:32:04.289 INFO:tasks.workunit.client.0.trial127.stderr:ceph config rm client rgw_debug_inject_olh_cancel_modification_err
  2026-10-29T13:32:04.512 INFO:tasks.workunit.client.0.trial127.stderr:ceph config rm client rgw_olh_pending_timeout_sec
  ...
  2026-10-29T13:32:14.348 INFO:tasks.workunit.client.0.trial127.stderr:Completed bucket versioning tests
  2026-10-29T13:32:14.390 INFO:tasks.workunit.client.0.trial127.stderr:+ echo OK.

@BBoozmen BBoozmen added TESTED and removed needs-qa wip-oozmen-testing for teuthology integration testing to be used via build-integration-branch.sh labels Oct 29, 2026
@BBoozmen
BBoozmen merged commit 9e49f5c into ceph:main Oct 29, 2026
18 checks passed
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.

2 participants