Skip to content

Commit e1ac09e

Browse files
author
Shilpa Jagannath
committed
rgw/multisite: reset RGW_ATTR_OBJ_REPLICATION_TRACE during object attr changes.
otherwise, if a zone receives request for any s3 object api requests like PutObjectAcl, PutObjectTagging etc. and this zone was originally the source zone for the object put request, then such subsequent sync ops will fail. this is because the zone id was added to the replication trace to ensure that we don't sync the object back to it. for example in a put/delete race during full sync(https://tracker.ceph.com/issues/58911) so, if the same zone ever becomes the destination for subsequent sync requests on the same object, we compare this zone as the destination zone against the zone entries in replication trace and because it's entry is already present in the trace, the sync operation returns -ERR_NOT_MODIFIED. Signed-off-by: Shilpa Jagannath <[email protected]>
1 parent 9bebe32 commit e1ac09e

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7421,7 +7421,20 @@ int RGWRados::set_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx* octx, RGWBu
74217421
if (!op.size())
74227422
return 0;
74237423

7424+
// remove replication-trace attr to be able to re-replicate an object when metadata changes
74247425
bufferlist bl;
7426+
const string replication_trace = RGW_ATTR_OBJ_REPLICATION_TRACE;
7427+
bool removed_attr{false};
7428+
r = state->get_attr(replication_trace, bl);
7429+
if (r < 0) {
7430+
ldpp_dout(dpp, 10) << "ERROR: cannot remove attr " << replication_trace.c_str() << dendl;
7431+
} else {
7432+
op.rmxattr(replication_trace.c_str());
7433+
removed_attr = true;
7434+
}
7435+
7436+
bl.clear();
7437+
74257438
RGWRados::Bucket bop(this, bucket_info);
74267439
RGWRados::Bucket::UpdateIndex index_op(&bop, obj);
74277440

@@ -7540,6 +7553,10 @@ int RGWRados::set_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx* octx, RGWBu
75407553
}
75417554
}
75427555

7556+
if (removed_attr) {
7557+
state->attrset.erase(replication_trace);
7558+
}
7559+
75437560
for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
75447561
state->attrset[iter->first] = iter->second;
75457562
}

src/rgw/driver/rados/rgw_sal_rados.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,8 +2848,10 @@ int RadosObject::modify_obj_attrs(const char* attr_name, bufferlist& attr_val, o
28482848
/* Temporarily set target */
28492849
state.obj = target;
28502850
set_atomic(true);
2851-
state.attrset[attr_name] = attr_val;
2852-
r = set_obj_attrs(dpp, &state.attrset, nullptr, y, flags);
2851+
2852+
Attrs mattr;
2853+
mattr[attr_name] = attr_val;
2854+
r = set_obj_attrs(dpp, &mattr, nullptr, y, flags);
28532855
/* Restore target */
28542856
state.obj = save;
28552857

src/test/rgw/rgw_multi/tests.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,14 +2317,14 @@ def test_object_acl():
23172317
before_set_acl = bucket2.get_acl(k)
23182318
assert(len(before_set_acl.acl.grants) == 1)
23192319

2320-
#set object acl on primary and wait for sync.
2321-
bucket.set_canned_acl('public-read', key_name=k)
2322-
log.debug('set acl=%s', bucket.name)
2320+
#set object acl on secondary and wait for sync.
2321+
bucket2.set_canned_acl('public-read', key_name=k)
2322+
log.debug('set acl=%s', bucket2.name)
23232323
zonegroup_data_checkpoint(zonegroup_conns)
2324-
zonegroup_bucket_checkpoint(zonegroup_conns, bucket.name)
2324+
zonegroup_bucket_checkpoint(zonegroup_conns, bucket2.name)
23252325

2326-
#check object secondary after setacl
2327-
bucket2 = get_bucket(secondary, bucket.name)
2326+
#check object on primary after setacl
2327+
bucket2 = get_bucket(primary, bucket.name)
23282328
after_set_acl = bucket2.get_acl(k)
23292329
assert(len(after_set_acl.acl.grants) == 2) # read grant added on AllUsers
23302330

0 commit comments

Comments
 (0)