Skip to content

allow configuring multiple object store backends - #52786

Merged
icewind1991 merged 4 commits into
masterfrom
multi-object-store
Aug 14, 2025
Merged

allow configuring multiple object store backends#52786
icewind1991 merged 4 commits into
masterfrom
multi-object-store

Conversation

@icewind1991

@icewind1991icewind1991 commented May 13, 2025

Copy link
Copy Markdown
Member

Allow configuring multiple object store backends to allow further load balancing and easier migration.

Configuration

Multiple object stores are configured by setting the objectstore system config to an array of object storage configurations instead of a single configuration. This array can contains both configuration items and references to other configuration keys (which functions as an alias).

When a the configured bucket for a user is an alias, the target of the alias is stored as the users chosen configuration instead to make migrations easier.
The "default" option is required to be an alias to prevent instances from accidentally being setup in a way that makes migration difficult.

By default everything is put in the "default" bucket, objects for the root storage are put in the "root" bucket if it exists ("default" if it doesn't), the backend for users can be set with a user preference option (occ user:setting <user> homeobjectstore objectstore <config key>).

Existing objectstore and objectstore_multibucket configurations are handled transparently.

Migration example

Migrating users to a new s3 server could be done with the following steps:

  • create a new object store configuration
  • update the default reference to the new configuration.

all new users will now be stored on the new s3 server, existing users can now be migrated one-by-one with minimal downtime

  • copy over the objects for a single user to the new s3 server
  • update the objectstore config key for the user

example configuration:

[
'objectstore' => [
'default' => 'new',
'new' => [
'class' => 'OC\\Files\\ObjectStore\\S3',
'arguments' => [
'multibucket' => true,
'bucket' => 'nextcloud-',
'hostname' => 'objectstore2',
...
],
],
'old' => [
'class' => 'OC\\Files\\ObjectStore\\S3',
'arguments' => [
'bucket' => 'nextcloud',
'hostname' => 'objectstore1',
...
],
],
'root' => [
'class' => 'OC\\Files\\ObjectStore\\S3',
'arguments' => [
'bucket' => 'nextcloud-root',
'hostname' => 'objectstore1',
...
],
],
],
]

For a use case where all objects in the root storage is put in "objectstore1/nextcloud-root", users created before the objectstore migration have the "homeobjectstore.objectstore" config option set to "old" and have their objects stored in "objectstore1/nextcloud" which all users created afterwards have their objects stored in the "objectstore2/nextcloud-XX" buckets.

todo

  • command to rename configurations
    • create "<new>" objectstore configuration as a copy from "<old>"
    • for all users who are currently using "<old>" set the objectstore config key to "<new>"
  • command to migrate users to a different config
  • command to list users by configuration

@icewind1991
icewind1991force-pushed the multi-object-store branch 6 times, most recently from cf36e0c to 95a019aCompareMay 14, 2025 08:37
@icewind1991
icewind1991force-pushed the multi-object-store branch 3 times, most recently from b2923b0 to 77b1e72CompareJune 2, 2025 15:58
@icewind1991
icewind1991force-pushed the multi-object-store branch 2 times, most recently from 16533d5 to 077003dCompareJune 5, 2025 15:42
@icewind1991
icewind1991force-pushed the multi-object-store branch 7 times, most recently from 14b8f17 to 2acc97cCompareJune 12, 2025 15:52
@icewind1991
icewind1991force-pushed the multi-object-store branch 4 times, most recently from 6440956 to 4a27074CompareJuly 31, 2025 15:41
@icewind1991icewind1991 added the 3. to review Waiting for reviews label Aug 1, 2025
@icewind1991icewind1991 added this to the Nextcloud 32 milestone Aug 1, 2025
@icewind1991
icewind1991 marked this pull request as ready for review August 1, 2025 14:10
Comment threadapps/files/lib/Command/Object/Multi/Rename.php Outdated
$query = $this->connection->getQueryBuilder();
$query->update('preferences')
->set('configvalue', $query->createNamedParameter($target))
->where($query->expr()->eq('appid', $query->createNamedParameter('homeobjectstore')))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s not an appid ⚠️
What about using core?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a separate "scope" makes it much easier to work with the values in bulk (see for example the query in the rename command).

Fwiw: homeobjectstore is already used as an appid for storing the bucket for the user.

Comment threadlib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php
Comment threadlib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php
@icewind1991
icewind1991force-pushed the multi-object-store branch 2 times, most recently from 53b0d3b to 404bce1CompareAugust 5, 2025 17:40

@salmart-devsalmart-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the object store, but the logic here makes sense in accordance to the PR's description.

@szaimen
szaimen removed their request for review August 11, 2025 11:51
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991
icewind1991 merged commit b691093 into masterAug 14, 2025
232 of 239 checks passed
@icewind1991
icewind1991 deleted the multi-object-store branch August 14, 2025 13:49
@skjnldsvskjnldsv mentioned this pull request Aug 19, 2025
@icewind1991

Copy link
Copy Markdown
MemberAuthor

/backport to stable31

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@icewind1991@salmart-dev@come-nc@skjnldsv