From: J. Eric Ivancich Date: Thu, 20 Jan 2022 15:57:32 +0000 (-0500) Subject: rgw: make bucket index pending op expiration configureable X-Git-Tag: v18.0.0~1183^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6e17a50497774a0aced555b90d87e56a1e510cb0;p=ceph.git rgw: make bucket index pending op expiration configureable 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 --- diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index d0046e87dc1f..0ef26edfd25c 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -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 @@ -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) { diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index 8e72f5081208..f26615249b77 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -17,10 +17,11 @@ #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 <<; diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index 53d7b10adeb5..39c5d3fb673c 100644 --- a/src/common/options/rgw.yaml.in +++ b/src/common/options/rgw.yaml.in @@ -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 diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 2bccf186e186..5a6eb7749927 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -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;