Bedrock.DataPlane.CommitProxy.Server (bedrock v0.5.3)
View SourceGenServer 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
- Initialization: Starts in
:lockedmode, waiting for recovery completion - Recovery: Director calls
recover_from/3to provide transaction system layout and unlock - Transaction Processing: Accepts
:commitcalls, batches transactions, and finalizes - Empty Transaction Timeout: Creates empty transactions during quiet periods to advance read versions
Batching Strategy
- Size-based: Batches finalize when reaching
max_per_batchtransactions - Time-based: Batches finalize after
max_latency_in_msmilliseconds - Immediate: Single transactions may bypass batching for low-latency processing
Timeout Mechanisms
- Fast timeout (0ms): Allows GenServer to process any queued
:commitmessages 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
@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.
@spec reply_fn(GenServer.from()) :: Bedrock.DataPlane.CommitProxy.Batch.reply_fn()