Project

General

Profile

Actions

Bug #68466

closed
JZ IG

multisite: olh entry update racing condition causes data inconsistency and potential data loss

Bug #68466: multisite: olh entry update racing condition causes data inconsistency and potential data loss

Added by Jane Zhu about 2 years ago. Updated 30 days ago.

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

0%

Pull request ID:
Tags (freeform):
Fixed In:
v20.3.0-3060-g297f7e5722
Released In:
v21.2.0~2057
Upkeep Timestamp:
2026-11-04T01:06:45+00:00

Description

Ceph versions affected: We found this issue on our customized Reef version, but it's reproducible (may with slight different behavior) on Squid and main.
Environment: active-active multisite settings with client traffic only going to the primary

What happened:

Our client reported that their GET request after a PUT (on the same object) returned 404 on their versioned bucket.

After some analysis, we realized that here is what happened:
  1. The client put a few versions of an object then delete the current version after a while.
  2. All of above operations were probably replicated to the secondary. As of now, all data were consistent and the object's olh entry in bucket index had the same epoch on both sites.
  3. LC kicked in on the secondary for the bucket and all non-current versions of the object as well as the delete marker were deleted.
  4. Somehow some pending operations were not properly cleaned and the olh entry was left behind with empty instance id, "pending_removal" as "true", and "exists" as "false".
  5. As of now, the epoch in the olh entry on the secondary was greater than the primary one at least by 2.
  6. A brand new PUT request came in on the primary for the same object name, and its "link_olh" op carried its epoch which was smaller than the current secondary epoch.
  7. When the above op was replicated to the secondary, the cls_rgw refused to promote the new instance as current since it carried a smaller epoch.
  8. As of now, the data inconsistency had been generated: the new instance was current on the primary but non-current on the secondary.
  9. LC kicked in again on the secondary and deleted the above bogus "non-current" version.
  10. The op was replicated back to the primary and the corresponding current version was deleted. Hence the data loss.

The last 2 steps (LC on secondary and its replication back to primary) won't happen in Squid and main since non-current version's expiration won't be replicated. But nothing prevents a client from manually or programmatically deleting a non-current version on the secondary in an active-active setting. So a data loss could still potentially happen there.

Even the data loss doesn't happen, the version inconsistency between 2 sites still prevent the DR from working properly.

I'll post a step-by-step reproducer on main using mstart shortly in the following update.


Related issues 2 (2 open — 0 closed)

Copied to rgw - Backport #73058: tentacle: multisite: olh entry update racing condition causes data inconsistency and potential data lossNewIgor Gomon

Actions
Copied to rgw - Backport #73059: squid: multisite: olh entry update racing condition causes data inconsistency and potential data lossIn ProgressAdam Emerson

Actions

JZ Updated by Jane Zhu about 2 years ago Actions #1

  • Affected Versions v18.0.0 added
  • Affected Versions deleted (v20.0.0)

JZ Updated by Jane Zhu about 2 years ago · Edited Actions #2

Reproducing steps on main using mstart

  1. start multisite clusters
    $ MON=1 OSD=1 MDS=0 MGR=0 RGW_PER_ZONE=1 ../ceph-src/src/test/rgw/test-rgw-multisite.sh 2
    
  2. create a rgw user
  3. on S3 client side
    $ s3cmd -c s3cfg.vstart mb s3://bar7
    $ aws s3api --profile vstart --endpoint=http://localhost:8101 put-bucket-versioning --bucket bar7 --versioning-configuration Status=Enabled
    $ s3cmd -c s3cfg.vstart put ../test_files/file_5m_0 s3://bar7/file_5m_0
    $ s3cmd -c s3cfg.vstart put ../test_files/file_5m_0 s3://bar7/file_5m_0
    
  4. on rgw: get bucket instance id
    $ bin/radosgw-admin -c /build/run/c1/ceph.conf bucket stats --bucket=bar7
    ...
    id: "50692d66-a1ed-445c-8ed1-075b7885e54b.4840.1" 
    ...
    
  5. on mon: check olh entries on both sites
    $ key=$(printf "\x80%s" 1001_file_5m_0); bin/rados -c /build/run/c1/ceph.conf -p zg1-1.rgw.buckets.index getomapval .dir.50692d66-a1ed-445c-8ed1-075b7885e54b.4840.1.1 $key olh_p.1
    $ bin/ceph-dencoder type rgw_bucket_olh_entry import olh_p.1 decode dump_json > olh_p_dump.1
    $ cat olh_p_dump.1
    {
        "key": {
            "name": "file_5m_0",
            "instance": "zLMu9oCPnFMyA2s0h9DhQlGCYUWbWkA" 
        },
        "delete_marker": false,
        "epoch": 3,
        "pending_log": [],
        "tag": "dmq0fndimb0rm3n0zwezafte3cynr3sc",
        "exists": true,
        "pending_removal": false
    }
    
    $ key=$(printf "\x80%s" 1001_file_5m_0); bin/rados -c /build/run/c2/ceph.conf -p zg1-2.rgw.buckets.index getomapval .dir.50692d66-a1ed-445c-8ed1-075b7885e54b.4840.1.1 $key olh_s.1
    $ bin/ceph-dencoder type rgw_bucket_olh_entry import olh_s.1 decode dump_json > olh_s_dump.1
    $ cat olh_s_dump.1
    {
        "key": {
            "name": "file_5m_0",
            "instance": "zLMu9oCPnFMyA2s0h9DhQlGCYUWbWkA" 
        },
        "delete_marker": false,
        "epoch": 3,
        "pending_log": [],
        "tag": "32tnjy7j530n1g0nun43m6mp4ni6h7z9",
        "exists": true,
        "pending_removal": false
    }
    
  6. on mon: disable replication sync on primary
    $ bin/ceph -c /build/run/c1/ceph.conf config set client.rgw rgw_run_sync_thread false
    
  7. on mon: set rgw_lc_debug_interval to 1 on secondary
    $ bin/ceph -c /build/run/c2/ceph.conf config set client.rgw rgw_lc_debug_interval 1
    
  8. restart rgws
    $ ../ceph-src/src/mrgw.sh c1 8101 0
    $ ../ceph-src/src/mrgw.sh c2 8201 0
    
  9. set lifecycle policy
    $ cat lc.xml
    <LifecycleConfiguration>
        <Rule>
            <ID>delete after 1 day</ID>
            <Prefix></Prefix>
            <Status>Enabled</Status>
            <Expiration>
                <Days>1</Days>
            </Expiration>
            <NoncurrentVersionExpiration>
                <NoncurrentDays>1</NoncurrentDays>
            </NoncurrentVersionExpiration>
        </Rule>
    </LifecycleConfiguration>
    $ s3cmd -c s3cfg.vstart --host http://localhost:8101 setlifecycle ./lc.xml s3://bar7.  <-- This should be able to be replicated to the secondary since the primary -> secondary replication is still on
    $ s3cmd -c s3cfg.vstart --host http://localhost:8201 setlifecycle ./lc.xml s3://bar7
    
  10. Wait till the LC has been processed on the secondary
    Bucket list output remains the same on primary, but on the secondary, all object versions & delete marker have been removed by LC.
    $ bin/radosgw-admin -c /build/run/c2/ceph.conf bucket list --bucket=bar7
    []
    
  11. on mon: check olh entries again on both sites. Please refer to step 5 for instructions.
    Primary:
    {
        "key": {
            "name": "file_5m_0",
            "instance": "zLMu9oCPnFMyA2s0h9DhQlGCYUWbWkA" 
        },
        "delete_marker": false,
        "epoch": 3,
        "pending_log": [],
        "tag": "dmq0fndimb0rm3n0zwezafte3cynr3sc",
        "exists": true,
        "pending_removal": false
    }
    

    Secondary:
    {
        "key": {
            "name": "file_5m_0",
            "instance": "" 
        },
        "delete_marker": false,
        "epoch": 7,
        "pending_log": [
            {
                "key": 7,
                "val": [
                    {
                        "epoch": 7,
                        "op": "unlink_olh",
                        "op_tag": "000000006706e0dfg6nw7wprrkkx3vqg",
                        "key": {
                            "name": "file_5m_0",
                            "instance": "" 
                        },
                        "delete_marker": false
                    }
                ]
            }
        ],
        "tag": "32tnjy7j530n1g0nun43m6mp4ni6h7z9",
        "exists": false,
        "pending_removal": true
    }
    
  12. delete LC policy to preserve the state after the following PUT
    $ s3cmd -c s3cfg.vstart --host http://localhost:8101 dellifecycle s3://bar7
    $ s3cmd -c s3cfg.vstart --host http://localhost:8201 dellifecycle s3://bar7
    
  13. S3 client side: put another version, and wait till replication finish
    s3cmd -c s3cfg.vstart put ../test_files/file_5m_0 s3://bar7/file_5m_0
    
  14. on rgw: check bucket list for data inconsistency
    Primary:
    [
        {
            "name": "file_5m_0",
            "instance": "3vuVbFCaRmEF2emdFIk3A9anG099rL.",
            "ver": {
                "pool": 7,
                "epoch": 141
            },
            "locator": "",
            "exists": true,
            "meta": {
                "category": 1,
                "size": 5242880,
                "mtime": "2024-10-09T20:01:16.392488Z",
                "etag": "900a1a7d4074c403c663ca007470907a",
                "storage_class": "STANDARD",
                "owner": "jzhu4",
                "owner_display_name": "jzhu4",
                "content_type": "application/octet-stream",
                "accounted_size": 5242880,
                "user_data": "",
                "appendable": false
            },
            "tag": "50692d66-a1ed-445c-8ed1-075b7885e54b.4921.1268187808127907070",
            "flags": 3,  <-- current version
            "pending_map": [],
            "versioned_epoch": 4
        },
        {
            "name": "file_5m_0",
            "instance": "zLMu9oCPnFMyA2s0h9DhQlGCYUWbWkA",
    ...
    

    Secondary:
    [
        {
            "name": "file_5m_0",
            "instance": "3vuVbFCaRmEF2emdFIk3A9anG099rL.",
            "ver": {
                "pool": 6,
                "epoch": 190
            },
            "locator": "",
            "exists": true,
            "meta": {
                "category": 1,
                "size": 5242880,
                "mtime": "2024-10-09T20:01:16.392488Z",
                "etag": "900a1a7d4074c403c663ca007470907a",
                "storage_class": "STANDARD",
                "owner": "jzhu4",
                "owner_display_name": "jzhu4",
                "content_type": "application/octet-stream",
                "accounted_size": 5242880,
                "user_data": "",
                "appendable": false
            },
            "tag": "_EUrObnm8bvi0JGmV8Kq4yAAKTzxmd36",
            "flags": 1,  <-- non-current version
            "pending_map": [],
            "versioned_epoch": 4
        }
    ]
    
  15. on mon: check olh entries again on both sites. Please refer to step 5 for instructions.
    Primary:
    {
        "key": {
            "name": "file_5m_0",
            "instance": "3vuVbFCaRmEF2emdFIk3A9anG099rL." 
        },
        "delete_marker": false,
        "epoch": 4,
        "pending_log": [],
        "tag": "dmq0fndimb0rm3n0zwezafte3cynr3sc",
        "exists": true,
        "pending_removal": false
    }
    

    Secondary: <-- unchanged, the same with step 11
    {
        "key": {
            "name": "file_5m_0",
            "instance": "" 
        },
        "delete_marker": false,
        "epoch": 7,
        "pending_log": [
            {
                "key": 7,
                "val": [
                    {
                        "epoch": 7,
                        "op": "unlink_olh",
                        "op_tag": "000000006706e0dfg6nw7wprrkkx3vqg",
                        "key": {
                            "name": "file_5m_0",
                            "instance": "" 
                        },
                        "delete_marker": false
                    }
                ]
            }
        ],
        "tag": "32tnjy7j530n1g0nun43m6mp4ni6h7z9",
        "exists": false,
        "pending_removal": true
    }
    
  16. restore the settings <-- this step is irrelevant to the issue
    $ bin/ceph -c /build/run/c2/ceph.conf config set client.rgw rgw_lc_debug_interval -1
    $ bin/ceph -c /build/run/c1/ceph.conf config set client.rgw rgw_run_sync_thread true
    $ ../ceph-src/src/mrgw.sh c1 8101 0
    $ ../ceph-src/src/mrgw.sh c2 8201 0
    
Now the data inconsistency established:
  • object version mismatch: instance "3vuVbFCaRmEF2emdFIk3A9anG099rL." is current on primary and non-current on secondary
  • dangling olh entry on secondary
The consequences of this data inconsistency:
  • all the following new instances of the same object are NOT able to be promoted to the current on secondary
  • non-current expiration LC or manual non-current version deletion on secondary will potentially result in data loss
  • GET or HEAD requests on the object against the secondary will not be able to get result back
    Primary:
    $ aws s3api --profile vstart --endpoint=http://localhost:8101 head-object --bucket bar7 --key file_5m_0
    {
        "AcceptRanges": "bytes",
        "Expiration": "expiry-date=\"Fri, 11 Oct 2024 00:00:00 GMT\", rule-id=\"delete after 1 day\"",
        "LastModified": "2024-10-09T20:05:40+00:00",
        "ContentLength": 5242880,
        "ETag": "\"900a1a7d4074c403c663ca007470907a\"",
        "VersionId": "ilZdbvaafusPmBhFDMImmbriVqTzQP9",
        "ContentType": "application/octet-stream",
        "Metadata": {
            "s3cmd-attrs": "atime:1728483224/ctime:1724954059/gid:90939/gname:jzhu4/md5:900a1a7d4074c403c663ca007470907a/mode:33204/mtime:1724954059/uid:90939/uname:jzhu4" 
        },
        "StorageClass": "STANDARD",
        "ReplicationStatus": "COMPLETED" 
    }
    

    Secondary:
    $ aws s3api --profile vstart --endpoint=http://localhost:8201 head-object --bucket bar7 --key file_5m_0
    An error occurred (404) when calling the HeadObject operation: Not Found
    
  • DR is not properly set: promoting the secondary to primary will result in missing object current version

JZ Updated by Jane Zhu about 2 years ago Actions #3

Please note: the LC doesn't have to be involved in order to create this type of data inconsistency. As long as, before the replication, the number of olh operations on the remote site is larger than the local site where a new PUT happens, we should be able to create a similar situation. Just the remote olh doesn't have to be dangling (left behind forever with empty instance id).
I was able to reproduce the data inconsistency with multiple ways of operation combinations.

JZ Updated by Jane Zhu about 2 years ago Actions #4

It looks like the issue is at the place where the new instance is being promoted to the current version during data sync.
I wonder if we can take into account the timestamp as well other than looking at the epoch only.

JZ Updated by Jane Zhu about 2 years ago Actions #5

Another issue we'd like to explore here is the recovery of the data from the inconsistent state.
It looks like the dangling olh entry (see the following example) can stay there forever. As I mentioned from the earlier update, it prevents all future new instances of the object from being promoted to the current version, so it has to be cleaned up. What's the best/safest way to do so?

Dangling olh entry example:

{
    "key": {
        "name": "file_5m_0",
        "instance": "" 
    },
    "delete_marker": false,
    "epoch": 7,
    "pending_log": [
        {
            "key": 7,
            "val": [
                {
                    "epoch": 7,
                    "op": "unlink_olh",
                    "op_tag": "000000006706e0dfg6nw7wprrkkx3vqg",
                    "key": {
                        "name": "file_5m_0",
                        "instance": "" 
                    },
                    "delete_marker": false
                }
            ]
        }
    ],
    "tag": "32tnjy7j530n1g0nun43m6mp4ni6h7z9",
    "exists": false,
    "pending_removal": true
}

JZ Updated by Jane Zhu about 2 years ago Actions #6

  • Affected Versions v18.1.0, v18.1.1, v18.1.2, v18.1.3, v18.2.0, v18.2.1, v18.2.2, v18.2.3, v18.2.4, v18.2.5, v19.1.0, v19.1.1, v19.2.0, v19.2.1, v20.0.0 added

JZ Updated by Jane Zhu about 2 years ago Actions #7

  • Assignee set to Igor Gomon

CB Updated by Casey Bodley about 2 years ago Actions #8

the proposal from Nov 20 weekly rgw meeting: use timestamps instead of olh epoch when determining the current version

regarding backward compatibility, maybe we don't need to do anything special?
  • new RGWs will set epoch=timestamp for uploads
  • old RGWs increment epoch for their uploads

during the upgrade period, old vs new uploads may not be ordered as expected, but all zones should still converge on the same result

part of this needs to happen on the OSD in cls_rgw (ex BIOLHEntry::start_modify() https://github.com/ceph/ceph/blob/801186f/src/cls/rgw/cls_rgw.cc#L1613-L1623), which gets upgraded separately from the RGWs. but as long as the new RGWs consistently pass in a valid timestamp for candidate_epoch, that should still work?

IG Updated by Igor Gomon about 2 years ago · Edited Actions #9

This sounds like an interesting idea. I will need to test this out with a mixed cluster, though, hopefully it works fine.

JI Updated by J. Eric Ivancich almost 2 years ago Actions #10

JI Updated by J. Eric Ivancich almost 2 years ago Actions #11

@janedevzhu @Jane Zhu : Do you know if this is being worked on?

IG Updated by Igor Gomon almost 2 years ago · Edited Actions #12

@J. Eric Ivancich Yes, this is being worked on, sorry for the delay. Will be posting updates on this soon. Thanks.

CB Updated by Casey Bodley over 1 year ago Actions #14

  • Status changed from New to Fix Under Review
  • Pull request ID set to 62469

JI Updated by J. Eric Ivancich over 1 year ago Actions #15

  • Backport set to squid tentacle

CB Updated by Casey Bodley about 1 year ago Actions #16

  • Status changed from Fix Under Review to Pending Backport

UB Updated by Upkeep Bot about 1 year ago Actions #17

  • Merge Commit set to 297f7e572294ece5bfcdcc4356bece68950cd13c
  • Fixed In set to v20.3.0-3060-g297f7e5722
  • Upkeep Timestamp set to 2025-09-16T22:11:41+00:00

UB Updated by Upkeep Bot about 1 year ago Actions #18

  • Copied to Backport #73058: tentacle: multisite: olh entry update racing condition causes data inconsistency and potential data loss added

UB Updated by Upkeep Bot about 1 year ago Actions #19

  • Copied to Backport #73059: squid: multisite: olh entry update racing condition causes data inconsistency and potential data loss added

UB Updated by Upkeep Bot about 1 year ago Actions #20

  • Tags (freeform) set to backport_processed

UB Updated by Upkeep Bot 3 months ago Actions #21

  • Status changed from Pending Backport to Backporting
  • Tags (freeform) deleted (backport_processed)
  • Upkeep Timestamp changed from 2025-09-16T22:11:41+00:00 to 2026-08-27T18:07:01+00:00

UB Updated by Upkeep Bot about 1 month ago Actions #22

  • Released In set to v21.2.0~2056
  • Upkeep Timestamp changed from 2026-08-27T18:07:01+00:00 to 2026-10-24T01:08:06+00:00

UB Updated by Upkeep Bot 30 days ago Actions #23

  • Released In changed from v21.2.0~2056 to v21.2.0~2057
  • Upkeep Timestamp changed from 2026-10-24T01:08:06+00:00 to 2026-11-04T01:06:45+00:00
Actions

Also available in: PDF Atom