[pbs-devel] [PATCH proxmox-backup v6 21/37] datastore: implement garbage collection for s3 backend
Christian Ebner
c.ebner at proxmox.com
Thu Jul 10 13:15:27 CEST 2025
On 7/10/25 11:47, Christian Ebner wrote:
> On 7/10/25 08:59, Thomas Lamprecht wrote:
>> I'm reading through this in not a very orderly fashion, so probably
>> won't be a very structured review, but some comments here and there.
>>
>> Am 08.07.25 um 19:00 schrieb Christian Ebner:
>>> Implements the garbage collection for datastore's backed by an s3
>>> object store.
>>> Take advantage of the local datastore by placing marker files in the
>>> chunk store during phase 1 of the garbage collection, updating their
>>> atime if already present. By this expensive api calls can be avoided
>>> to update the object metadata (only possible via a copy object
>>> operation).
>>
>> The last sentence would be IMO slightly easier to understand:
>>
>> This allows us to avoid making expensive API calls to update object
>> metadata, which would only be possible via a copy object operation.
>>
>>>
>>> The phase 2 is implemented by fetching a list of all the chunks via
>>> the ListObjectsV2 api call, filtered by the chunk folder prefix.
>>> This operation has to be performed in patches of 1000 objects, given
>>
>> s/patches/batches/
>>
>>> by the api's response limits.
>>> For each object key, lookup the marker file and decide based on the
>>> marker existence and it's atime if the chunk object needs to be
>>> removed. Deletion happens via the delete objects operation, allowing
>>> to delete multiple chunks by a single request.
>>>
>>> This allows to efficiently lookup chunks which are not in use
>>> anymore while being performant and cost effective.
>>
>> Do you got some rough numbers perchance? E.g., something like "a
>> datastore with X indexes, Y acutal data and Z deduplication factor
>> is garbage collect in T time on:" and then the time numbers for
>> e.g. ceph RGW backed S3, AWS/Cloudlflare S3/R2 and file system,
>> just to get some idea of the ballpark we're in, and can also help
>> to have such numbers as baseline for potential future optimization
>> experiments.
>
> Ran into issues with GC returning sometimes 400 bad request errors while
> performing the baseline performance test.
> Interestingly only on AWS, Cloudflare R2 and RADOS Gateway work as
> expected.
>
> I'm currently investigating, but this seems related to the next
> continuation token in the list object v2 requests.
Found and fixed the culprit: The issue here was the continuation token
not being uri encoded, but being passed along as query parameter to the
api request. This was an issue, since the token returned by AWS are
base64 encoded, therefore might contain equal signs.
Fixed this by reworking the encoding logic, instead of already encoding
the strings in the S3ObjectKey, encode the path and all query parameters
in the s3 client's `build_uri` helper, which is used by all api calls
anyways. It makes actually more sense to have it there, as then object
keys can be parsed/passed in the body without encoding/decoding steps.
More information about the pbs-devel
mailing list