Skip to content

Commit

Permalink
Merge pull request #51071 from ivancich/wip-versioned-reindex
Browse files Browse the repository at this point in the history
rgw: reindex of objects in versioned buckets

Reviewed-by: Casey Bodley <[email protected]>
  • Loading branch information
ivancich authored Sep 7, 2023
2 parents abfede8 + 89f8121 commit 815481c
Show file tree
Hide file tree
Showing 13 changed files with 627 additions and 186 deletions.
1 change: 1 addition & 0 deletions ceph.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,7 @@ exit 0
%{_mandir}/man8/rbd-replay-many.8*
%{_mandir}/man8/rbd-replay-prep.8*
%{_mandir}/man8/rgw-orphan-list.8*
%{_mandir}/man8/rgw-restore-bucket-index.8*
%dir %{_datadir}/ceph/
%{_datadir}/ceph/known_hosts_drop.ceph.com
%{_datadir}/ceph/id_rsa_drop.ceph.com
Expand Down
1 change: 1 addition & 0 deletions debian/radosgw.install
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ usr/bin/radosgw-token
usr/share/man/man8/ceph-diff-sorted.8
usr/share/man/man8/radosgw.8
usr/share/man/man8/rgw-orphan-list.8
usr/share/man/man8/rgw-restore-bucket-index.8
3 changes: 2 additions & 1 deletion doc/man/8/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ if(WITH_RADOSGW)
radosgw-admin.rst
rgw-orphan-list.rst
rgw-policy-check.rst
ceph-diff-sorted.rst)
ceph-diff-sorted.rst
rgw-restore-bucket-index.rst)
endif()

if(WITH_RBD)
Expand Down
3 changes: 3 additions & 0 deletions doc/man/8/radosgw-admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ as follows:
:command:`object rewrite`
Rewrite the specified object.

:command:`object reindex`
Add an object to its bucket's index. Used rarely for emergency repairs.

:command:`objects expire`
Run expired objects cleanup.

Expand Down
106 changes: 106 additions & 0 deletions doc/man/8/rgw-restore-bucket-index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
:orphan:

==================================================================================
rgw-restore-bucket-index -- try to restore a bucket's objects to its bucket index
==================================================================================

.. program:: rgw-restore-bucket-index

Synopsis
========

| **rgw-restore-bucket-index**
Description
===========

:program:`rgw-restore-bucket-index` is an *EXPERIMENTAL* RADOS gateway
user administration utility. It scans the data pool for objects that
belong to a given bucket and tries to add those objects back to the
bucket index. It's intended as a **last resort** after a
**catastrophic** loss of a bucket index. Please thorougly review the
*Warnings* listed below.

The utility works with regular (i.e., un-versioned) buckets, versioned
buckets, and buckets were versioning has been suspended.

Warnings
========

This utility is currently considered *EXPERIMENTAL*.

The results are unpredictable if the bucket is in
active use while this utility is running.

The results are unpredictable if only some bucket's objects are
missing from the bucket index. In such a case, consider using the
"object reindex" subcommand of `radosgw-admin` to restore object's to
the bucket index one-by-one.

For objects in versioned buckets, if the latest version is a delete
marker, it will be restored. If a delete marker has been written over
with a new version, then that delete marker will not be restored. This
should have minimal impact on results in that the it recovers the
latest version and previous versions are all accessible.

Command-Line Arguments
======================

.. option:: -b <bucket>

Specify the bucket to be reindexed.

.. option:: -p <pool>

Optional, specify the data pool containing head objects for the
bucket. If omitted the utility will try to determine the data pool
on its own.

.. option:: -r <realm-name>

Optional, specify the realm if the restoration is not being applied
to the default realm.

.. option:: -g <zonegroup-name>

Optional, specify the zonegroup if the restoration is not being applied
to the default zonegroup.

.. option:: -z <zone-name>

Optional, specify the zone if the restoration is not being applied
to the default zone.

.. option:: -l <rados-ls-output-file>

Optional, specify a file containing the output of a rados listing
of the data pool. Since listing the data pool can be an expensive
and time-consuming operation, if trying to recover the indices for
multiple buckets, it could be more efficient to re-use the same
listing.

.. option:: -y

Optional, proceed without further prompting. Without this option
the utility will display some information and prompt the user as to
whether to proceed. When provided, the utility will simply
proceed. Please use caution when using this option.

Examples
========

Attempt to restore the index for a bucket named *summer-2023-photos*::

$ rgw-restore-bucket-index -b summer-2023-photos

Availability
============

:program:`rgw-restore-bucket-index` is part of Ceph, a massively
scalable, open-source, distributed storage system. Please refer to
the Ceph documentation at https://docs.ceph.com for more information.

See also
========

:doc:`radosgw-admin <radosgw-admin>`\(8)
1 change: 1 addition & 0 deletions doc/man_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@
man/8/ceph-immutable-object-cache
man/8/ceph-diff-sorted
man/8/rgw-policy-check
man/8/rgw-restore-bucket-index
4 changes: 3 additions & 1 deletion src/cls/rgw/cls_rgw_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ void cls_rgw_bucket_complete_op(ObjectWriteOperation& o, RGWModifyOp op, const s
const rgw_bucket_dir_entry_meta& dir_meta,
const list<cls_rgw_obj_key> *remove_objs, bool log_op,
uint16_t bilog_flags,
const rgw_zone_set *zones_trace)
const rgw_zone_set *zones_trace,
const std::string& obj_locator)
{

bufferlist in;
Expand All @@ -295,6 +296,7 @@ void cls_rgw_bucket_complete_op(ObjectWriteOperation& o, RGWModifyOp op, const s
call.tag = tag;
call.key = key;
call.ver = ver;
call.locator = obj_locator;
call.meta = dir_meta;
call.log_op = log_op;
call.bilog_flags = bilog_flags;
Expand Down
3 changes: 2 additions & 1 deletion src/cls/rgw/cls_rgw_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ void cls_rgw_bucket_complete_op(librados::ObjectWriteOperation& o, RGWModifyOp o
const cls_rgw_obj_key& key,
const rgw_bucket_dir_entry_meta& dir_meta,
const std::list<cls_rgw_obj_key> *remove_objs, bool log_op,
uint16_t bilog_op, const rgw_zone_set *zones_trace);
uint16_t bilog_op, const rgw_zone_set *zones_trace,
const std::string& obj_locator = ""); // ignored if it's the empty string

void cls_rgw_remove_obj(librados::ObjectWriteOperation& o, std::list<std::string>& keep_attr_prefixes);
void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation& o, const std::string& attr);
Expand Down
Loading

0 comments on commit 815481c

Please sign in to comment.