]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: make bucket index pending op expiration configureable
authorJ. Eric Ivancich <ivancich@redhat.com>
Thu, 20 Jan 2022 15:57:32 +0000 (10:57 -0500)
committerJ. Eric Ivancich <ivancich@redhat.com>
Thu, 24 Mar 2022 16:16:17 +0000 (12:16 -0400)
Bucket index operations are transactional with data object
manipulation. The operation is prepared by adding a pending operation
record. And when the data object side is complete, the bucket index
operation is committed.

If it fails to be committed, later bucket listings will compare the
pending ops with the current data object state and see whether it
completed or not and then either commit or expire the op. The time
span for expiration is currently hard-coded as 120 seconds (unless
overridden in the bucket header, which can happen during "bucket
check").

This commit allows that expiration time to be configured.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_types.h
src/common/options/rgw.yaml.in
src/rgw/rgw_bucket.cc

index d0046e87dc1f868618e1823afb69db07dd9a5d1f..0ef26edfd25c8f31d13aa536f8e186ef2266333a 100644 (file)
@@ -13,6 +13,7 @@
 #include "common/Clock.h"
 #include "common/strtol.h"
 #include "common/escape.h"
+#include "common/config_proxy.h"
 
 #include "include/compat.h"
 #include <boost/lexical_cast.hpp>
@@ -2157,6 +2158,8 @@ int rgw_dir_suggest_changes(cls_method_context_t hctx,
 {
   CLS_LOG(1, "entered %s", __func__);
 
+  const ConfigProxy& conf = cls_get_config(hctx);
+
   bufferlist header_bl;
   rgw_bucket_dir_header header;
   bool header_changed = false;
@@ -2167,9 +2170,18 @@ int rgw_dir_suggest_changes(cls_method_context_t hctx,
     return rc;
   }
 
+  const uint64_t config_op_expiration =
+    conf->rgw_pending_bucket_index_op_expiration;
+
+  // priority order -- 1) bucket header, 2) global config, 3) DEFAULT;
+  // a value of zero indicates go down the list
   timespan tag_timeout(
     std::chrono::seconds(
-      header.tag_timeout ? header.tag_timeout : CEPH_RGW_TAG_TIMEOUT));
+      header.tag_timeout ?
+      header.tag_timeout :
+      (config_op_expiration ?
+       config_op_expiration :
+       CEPH_RGW_DEFAULT_TAG_TIMEOUT)));
 
   auto in_iter = in->cbegin();
 
@@ -2289,8 +2301,9 @@ int rgw_dir_suggest_changes(cls_method_context_t hctx,
   if (header_changed) {
     return write_bucket_header(hctx, &header);
   }
+
   return 0;
-}
+} // rgw_dir_suggest_changes
 
 static int rgw_obj_remove(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 {
index 8e72f50812086d046dbc1fb8bec18d1c633aa024..f26615249b771745e7e4b26b77e14e22c2fb6fe4 100644 (file)
 
 #define CEPH_RGW_REMOVE 'r'
 #define CEPH_RGW_UPDATE 'u'
-#define CEPH_RGW_TAG_TIMEOUT 120
 #define CEPH_RGW_DIR_SUGGEST_LOG_OP  0x80
 #define CEPH_RGW_DIR_SUGGEST_OP_MASK 0x7f
 
+constexpr uint64_t CEPH_RGW_DEFAULT_TAG_TIMEOUT = 120; // in seconds
+
 class JSONObj;
 
 using ceph::operator <<;
index 53d7b10adeb5b5521fb2b43e7201a50175da5391..39c5d3fb673c4fc83f5de4d59f4e553482035301 100644 (file)
@@ -3304,3 +3304,16 @@ options:
   services:
   - rgw
   with_legacy: true
+- name: rgw_pending_bucket_index_op_expiration
+  type: uint
+  level: advanced
+  default: 120
+  desc: Number of seconds a pending operation can remain in bucket index shard.
+  long_desc: Number of seconds a pending operation can remain in bucket
+    index shard before it expires. Used for transactional bucket index
+    operations, and if the operation does not complete in this time
+    period, the operation will be dropped.
+  services:
+  - rgw
+  - osd
+  with_legacy: true
index 2bccf186e1862635b27018ae13b62ca31422ddb7..5a6eb77499279140c1b1d8c2f56bbf669355cdc9 100644 (file)
@@ -55,7 +55,8 @@
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rgw
 
-#define BUCKET_TAG_TIMEOUT 30
+// seconds for timeout during RGWBucket::check_object_index
+constexpr uint64_t BUCKET_TAG_QUICK_TIMEOUT = 30;
 
 using namespace std;
 
@@ -601,7 +602,8 @@ int RGWBucket::check_object_index(const DoutPrefixProvider *dpp,
     return -EINVAL;
   }
 
-  bucket->set_tag_timeout(dpp, BUCKET_TAG_TIMEOUT);
+  // use a quicker/shorter tag timeout during this process
+  bucket->set_tag_timeout(dpp, BUCKET_TAG_QUICK_TIMEOUT);
 
   rgw::sal::Bucket::ListResults results;
   results.is_truncated = true;
@@ -627,6 +629,7 @@ int RGWBucket::check_object_index(const DoutPrefixProvider *dpp,
 
   formatter->close_section();
 
+  // restore normal tag timeout for bucket
   bucket->set_tag_timeout(dpp, 0);
 
   return 0;