Over time, data may be distributed unevenly between the database's shards, until
some shards may host and handle a much bigger portion of the overall load than others.
Resharding is the process of re-distributing stored data between the shards.
Keeping about the same amount of data on all shards helps maintain an equal
level of resource usage and improves the database's overall availability and
Resharding is currently manual.
Resharding can currently be initiated manually, via Studio.
RavenDB provides a comfortable resharding interface and does alert
its users when disk space and other resources are exhausted, but it
is up to you to commence the resharding process when it is needed.
Resharding is carried out one bucket at a time.
The smallest unit that can be resharded is a single bucket with all its contents.
It is also possible to reshard ranges of buckets, but resharding is always done
one bucket at a time to keep the process light, avoiding any additional burden to
shards that may already be preoccupied.
The Resharding Process
Let's follow the resharding of a range of buckets from shard #0 to shard #2,
using a database like the one shown below:
- The client requests to reshard buckets from shard
#0 to shard
#0 connects shard
#2 and transfers to it all the content of the first bucket.
#0 remains the owner of the bucket until all data has been propagated to
- The ownership is transferred, the bucket is remapped to shard
#0 starts purging all the entities whose ownership is now held by shard
If there are still buckets to shift, shard
#0 can start transferring content from the next bucket.
Following Resharding Progress
You can follow the progress of the resharding progress using -
Studio Popup Messages
When Studio is used for resharding
the user interface produces popup messages to keep users
informed of its progress.
The Database Record
All sharding-related info is stored in the database record
property, where this info can be accessed by all shards.
During resharding, migrating buckets details like status, source shard,
and destination shard, are updated in related
Open Studio's Database Record view and the Sharding property.
The details of currently-migrating buckets are recorded in
1. Click to open the Settings
2. Click to view or edit the database record
To get the database record via API, pass
Open the database record
BucketMigration property to check migrating buckets
status, source and destination shards.
It may happen that a file (like a time series, due to the addition
of a time series entry) would find its way into a bucket after the
ownership of this bucket has already been shifted to another shard
and before RavenDB managed to delete it.
To handle such occurences, a periodic documents migrator task
routinely checks the system.
Upon locating a file in a bucket that is already owned by another shard,
the documents migrator task immediately initiates a new resharding process
for the related bucket.