]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix data corruption when rados op return ETIMEDOUT
authorlu.shasha <lu.shasha@aishu.cn>
Tue, 3 Dec 2024 07:46:35 +0000 (15:46 +0800)
committerlu.shasha <lu.shasha@aishu.cn>
Thu, 19 Dec 2024 07:56:43 +0000 (15:56 +0800)
when rados op return ETIMEOUT, rgw can't determine whether or not the rados op succeeded,
To avoid data corruption, when return -ETIMEDOUT, we should clear all objects in RadosWriter

Signed-off-by: Shasha Lu <lu.shasha@aishu.cn>
(cherry picked from commit 23fcab7fc6b4b4aa3c1d06f65eb4e7ebb0e86311)

src/rgw/driver/rados/rgw_putobj_processor.cc

index d41678cdb06b816a94931974819a357c73eb13c4..d185fd76f620d93660d4c81d9b8a4cac07eda76b 100644 (file)
@@ -586,6 +586,11 @@ int MultipartObjectProcessor::complete(size_t accounted_size,
     r = rgw_rados_operate(rctx.dpp, meta_obj_ref.ioctx, meta_obj_ref.obj.oid, &op, rctx.y);
   }
   if (r < 0) {
+    if (r == -ETIMEDOUT) {
+      // The meta_obj_ref 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 == -ENOENT ? -ERR_NO_SUCH_UPLOAD : r;
   }
 
@@ -766,6 +771,11 @@ int AppendObjectProcessor::complete(size_t accounted_size, const string &etag, c
                        accounted_size + *cur_accounted_size,
                        attrs, rctx, writer.get_trace(), flags & rgw::sal::FLAG_LOG_OP);
   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;
   }
   if (!obj_op.meta.canceled) {