mix malachi.reshard (malachi v0.22.7)

View Source

Grows the cluster's metadata sharding: the number of vnodes (Raft-backed metadata shards) - on a running Malachi node, over Erlang distribution (RPC).

mix malachi.reshard --to 16

Each additional vnode is created by one split of the vnode owning the largest hash arc: a new ra cluster is started and the displaced topics' metadata is migrated to it (fenced, copy-first), then the versioned ring is published and gossiped so every node routes to the new shard. Splits run one at a time, driven only by the node holding the cluster lease.

Growing is resumable: if a reshard is interrupted, re-run the same --to target and it continues from the current ring: the splits already done are reflected in it. Only growing is supported; a target below the current count is rejected.

The grown ring is durable: each step records it in the cluster's ring store before gossiping it, and at boot that record outranks MALACHI_LOG_VNODES, so a reshard survives a full-cluster restart. mix malachi.ring --show prints what is recorded.

Options:

  • --to: the target vnode count (required; must exceed the current count)
  • --node: the target node (default $MALACHI_NODE or malachi@127.0.0.1)
  • --cookie: the Erlang cookie (default $RELEASE_COOKIE, else ~/.erlang.cookie)

The target node must be named and running a sharded control plane (MALACHI_LOG_VNODES > 1 with a clustered log); otherwise there is no ring to grow.

Summary

Functions

The testable core: asks the remote ReshardCoordinator to grow to --to through call (a (module, fun, args -> {:ok, value} | {:error, reason}) seam that in production is an RPC to the target node). Returns {:ok, message} / {:error, message} for the caller to print.

Functions

execute(arg1, opts, call)

@spec execute([String.t()], keyword(), (module(), atom(), list() ->
                                    {:ok, term()} | {:error, term()})) ::
  {:ok, String.t()} | {:error, String.t()}

The testable core: asks the remote ReshardCoordinator to grow to --to through call (a (module, fun, args -> {:ok, value} | {:error, reason}) seam that in production is an RPC to the target node). Returns {:ok, message} / {:error, message} for the caller to print.