Bedrock.DataPlane.CommitProxy.Server (bedrock v0.5.3)

View Source

GenServer implementation of the Commit Proxy.

Overview

The Commit Proxy batches transaction requests from clients to optimize throughput while maintaining strict consistency guarantees. It coordinates with resolvers for conflict detection and logs for durable persistence.

Lifecycle

  1. Initialization: Starts in :locked mode, waiting for recovery completion
  2. Recovery: Director calls recover_from/3 to provide transaction system layout and unlock
  3. Transaction Processing: Accepts :commit calls, batches transactions, and finalizes
  4. Empty Transaction Timeout: Creates empty transactions during quiet periods to advance read versions

Batching Strategy

  • Size-based: Batches finalize when reaching max_per_batch transactions
  • Time-based: Batches finalize after max_latency_in_ms milliseconds
  • Immediate: Single transactions may bypass batching for low-latency processing

Timeout Mechanisms

  • Fast timeout (0ms): Allows GenServer to process any queued :commit messages before finalizing the current batch, ensuring optimal batching efficiency
  • Empty transaction timeout: Creates empty {nil, %{}} transactions during quiet periods to keep read versions advancing and provide system health checking

Error Handling

Uses fail-fast recovery model where unrecoverable errors (sequencer unavailable, log failures) trigger process exit and Director-coordinated cluster recovery.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

@spec child_spec(
  opts :: [
    cluster: Bedrock.Cluster.t(),
    director: pid(),
    epoch: Bedrock.epoch(),
    lock_token: Bedrock.lock_token(),
    instance: non_neg_integer(),
    sequencer: pid(),
    resolver_layout: Bedrock.DataPlane.CommitProxy.ResolverLayout.t(),
    max_latency_in_ms: non_neg_integer(),
    max_per_batch: pos_integer(),
    empty_transaction_timeout_ms: non_neg_integer()
  ]
) :: Supervisor.child_spec() | no_return()

Returns a specification to start this module under a supervisor.

See Supervisor.

reply_fn(from)