]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: auto-create missing bucket index shards during reindex operations 64801/head
authorJoshua Blanch <joshua.blanch@clyso.com>
Thu, 31 Jul 2025 22:31:37 +0000 (22:31 +0000)
committerJoshua Blanch <joshua.blanch@clyso.com>
Tue, 5 Aug 2025 22:13:52 +0000 (22:13 +0000)
When bucket indexes are purged (e.g., via `radosgw-admin bi purge`),
reindex operations fail because they attempt to update non-existent
bucket index shards.

Fixes: https://tracker.ceph.com/issues/68750
Signed-off-by: Joshua Blanch <joshua.blanch@clyso.com>
src/rgw/driver/rados/rgw_rados.cc

index 4ab7fe06e94f2343f6d1b39c3d1403ebda14f746..e3dd956741c0d976a4b7bc721e325f7cf50f20ce 100644 (file)
@@ -4088,6 +4088,39 @@ int RGWRados::reindex_obj(rgw::sal::Driver* driver,
     (void) decode_policy(dpp, acl_bl, &owner);
   }
 
+  rgw_rados_ref bucket_ref;
+  ret = svc.bi_rados->open_bucket_index_shard(dpp, 
+                                             bucket_info, 
+                                             head_obj.get_hash_object(), 
+                                             &bucket_ref, 
+                                             nullptr);
+  if (ret < 0) {
+    ldpp_dout(dpp, 0) << "ERROR: failed to determine bucket index shard"
+                      << dendl;
+    return ret;
+  }
+
+  // validate bucket index shard existence before attempting reindex
+  ret = bucket_ref.ioctx.stat(bucket_ref.obj.oid, NULL, NULL);
+  if (ret == -ENOENT) {
+    ldpp_dout(dpp, 10) << "INFO: bucket index shard " << bucket_ref.obj.oid
+                       << " missing, creating..." << dendl;
+    int create_ret = svc.bi_rados->init_index(dpp, 
+                                             y, 
+                                             bucket_info, 
+                                             bucket_info.layout.current_index, 
+                                             false);
+
+    if (create_ret < 0) {
+      ldpp_dout(dpp, 0) << "ERROR: failed to create bucket index" << dendl;
+      return create_ret;
+    }
+  } else if (ret < 0) {
+    ldpp_dout(dpp, 0) << "ERROR: failed to stat bucket index shard: "
+                      << cpp_strerror(-ret) << dendl;
+    return ret;
+  }
+
   Bucket bkt(this, bucket_info);
   RGWRados::Bucket::UpdateIndex update_idx(&bkt, head_obj);