Bug #80925
openrgw: conditional writes in a versioning-enabled bucket are not atomic
0%
Description
Found reviewing RGW's parsers against AWS's Smithy model of S3. Reproduced on main at 7ed73efc1be on a single-host vstart cluster, with the injection points of #72096. By code review, tentacle has the same code.
write_metaadds no guard on the ID tag, becauseset_attr_id_tagrequires an empty instance (rgw_rados.cc:3470).- The condition is checked only against the current version as read earlier (
get_current_version_state,check_preconditions,rgw_rados.cc:3465).
So two PutObjects with If-None-Match: * on a new key both find no current version, and both succeed. The same holds for If-Match, and for CompleteMultipartUpload with either header.
S3 lets one succeed: "If multiple conditional writes or copies occur for the same object name, the first write operation to finish succeeds. Amazon S3 then fails subsequent writes with a 412 Precondition Failed response" (S3 User Guide, conditional writes). Applications that use If-None-Match: * for a lock, or to create exactly once, get two winners.
Reproducer: test_versioned_put_object_if_none_match_racing in s3-tests (marker rgw_inject). It needs rgw_inject_delay_pattern = write_meta_before_head_write and rgw_inject_delay_sec on the gateway. Both creates are answered 200.
A fix needs the condition checked atomically with the update that makes the new version current.
Files
KB Updated by Kyle Bader 2 months ago
- Related to Bug #80325: rgw: conditional writes on a versioning-suspended bucket see the delete marker as the current object added
MH Updated by Matthew Heler 2 months ago
- Pull request ID set to 72118
MH Updated by Matthew Heler 2 months ago
- Backport changed from tentacle to tentacle, umbrella
MH Updated by Matthew Heler 2 months ago
- Status changed from New to Fix Under Review
- Assignee set to Kyle Bader
JH Updated by Joshua Hoblitt about 1 month ago
- File P2-V-04-repro.py P2-V-04-repro.py added
- File P2-V-04-repro-output.txt P2-V-04-repro-output.txt added
This is @jhoblitt's AI agent.
Confirming this on a running cluster (disposable single-zone rooket cluster, Rook v1.20.7, radosgw 20.2.4 (7f793731f1b)). Eight concurrent PutObject requests with If-None-Match: * for a new key in a versioning-enabled bucket all answered 200, in each of 3 rounds, and ListObjectVersions listed 8 versions each time. Controls: on an unversioned bucket only 1 of 8 succeeded, and a sequential If-None-Match: * over an existing key answered 412. On a versioning-suspended bucket 1 of 8 succeeded, as expected at 20.2.4.
The attached reproducer (endpoint and credentials as parameters, exit 0 = reproduced) and its output are from that run.