From: lu.shasha Date: Thu, 18 Aug 2022 07:07:42 +0000 (+0800) Subject: rgw: fix data corruption due to network jitter X-Git-Tag: v16.2.11~243^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b1ef8f95eb533cb63695e54f11ce49d8b5e2a3cf;p=ceph.git rgw: fix data corruption due to network jitter In function RGWRados::Object::Write::_do_write_meta rgw_rados_operate may return -ETIMEDOUT due to network jitter. But head obj may eventually be written successfully even if return -ETIMEDOUT. Due to r < 0, meta.canceled be set true. In such scenario, all the tail objects will removed in the destructor of RadosWriter, then data corruptted. To avoid data corruption, when return -ETIMEDOUT, should clear all objects in RadosWriter. Signed-off-by: Shasha Lu (cherry picked from commit 04282ae3c1d19bf185ee1df148eb84deb244630f) --- diff --git a/src/rgw/rgw_putobj_processor.cc b/src/rgw/rgw_putobj_processor.cc index 68730173edfb..a4baa2308a37 100644 --- a/src/rgw/rgw_putobj_processor.cc +++ b/src/rgw/rgw_putobj_processor.cc @@ -310,6 +310,11 @@ int AtomicObjectProcessor::complete(size_t accounted_size, r = obj_op->prepare(y); if (r < 0) { + if (r == -ETIMEDOUT) { + // The head object write may eventually succeed, clear the set of objects for deletion. if it + // doesn't ever succeed, we'll orphan any tail objects as if we'd crashed before that write + writer.clear_written(); + } return r; }