REBALANCE_SHARDS

Rebalances shard assignments across a cluster in Eon Mode. If the current session ends, the operation immediately aborts. The amount of time required to rebalance shards scales in a roughly linear fashion based on the number of objects in your database.

Run REBALANCE_SHARDS after you modify your cluster using ALTER NODE.

After you rebalance shards, you will no longer be able to restore objects from a backup taken before the rebalancing. (Full backups are always possible.) After you rebalance, make another full backup so you will be able to restore objects from it in the future.

Syntax

REBALANCE_SHARDS()

Privileges

Superuser

Examples

The following example rebalances the shards of all the nodes in the database:

=> SELECT REBALANCE_SHARDS();
 REBALANCE_SHARDS  
-------------------
 REBALANCED SHARDS
(1 row)

After running REBALANCE_SHARDS check the subscription status by querying the SESSION_SUBSCRIPTIONS table, for example:

=> SELECT * from session_subscriptions where is_participating='t' order by node_name, shard_name;

node_oid           | node_name  | shard_oid          |  shard_name     | is_participating
-------------------+------------+--------------------+-----------------+-----------
45035996273704978  |  node01    | 45035996273704980  | replica         | t
45035996273704978  |  node01    | 45035996273704992  | segment003      | t
45035996273705124  |  node02    | 45035996273704980  | replica         | t
45035996273705124  |  node02    | 45035996273704988  | segment002      | t
45035996273946332  |  node04    | 45035996273704984  | segment001      | t