Bedrock.ControlPlane.Director.Recovery.ResolverStartupPhase (bedrock v0.5.3)

View Source

Solves the critical concurrency control challenge by starting resolver components that implement MVCC conflict detection.

Transforms resolver descriptors from vacancy creation into operational resolver processes that are immediately ready to handle transaction conflict detection.

Uses round-robin distribution across resolution-capable nodes from context.node_capabilities.resolution, ensuring fault tolerance by spreading resolvers across different machines. Resolvers start directly in running mode without requiring recovery coordination.

Stalls if no resolution-capable nodes are available or if individual resolver startup fails since conflict detection is fundamental to transaction isolation guarantees.

Summary

Functions

child_spec_for_resolver(epoch, key_range, lock_token, last_committed_version, director, cluster)

@spec child_spec_for_resolver(
  epoch :: Bedrock.epoch(),
  key_range :: Bedrock.key_range(),
  lock_token :: Bedrock.lock_token(),
  last_committed_version :: Bedrock.version(),
  director :: pid(),
  cluster :: module()
) :: Supervisor.child_spec()

define_resolvers(context)

@spec define_resolvers(%{
  resolvers: [Bedrock.ControlPlane.Config.ResolverDescriptor.t()],
  epoch: Bedrock.epoch(),
  available_nodes: [node()],
  start_supervised_fn: (Supervisor.child_spec(), node() ->
                          {:ok, pid()} | {:error, term()}),
  lock_token: Bedrock.lock_token(),
  last_committed_version: Bedrock.version(),
  cluster: module()
}) ::
  {:ok, [{start_key :: Bedrock.key(), resolver :: pid()}]}
  | {:error, {:failed_to_start, :resolver, node(), reason :: term()}}

start_resolvers(resolver_boot_info, available_nodes, start_supervised)

@spec start_resolvers(
  resolver_boot_info :: [{Supervisor.child_spec(), start_key :: Bedrock.key()}],
  available_nodes :: [node()],
  start_supervised :: (Supervisor.child_spec(), node() ->
                         {:ok, pid()} | {:error, term()})
) ::
  {:ok, [{start_key :: Bedrock.key(), resolver :: pid()}]}
  | {:error, {:failed_to_start, :resolver, node(), reason :: term()}}