hindsight-postgresql-store
Copyright(c) 2024
LicenseBSD3
Maintainermaintainer@example.com
Stabilityinternal
Safe HaskellNone
LanguageGHC2021

Hindsight.Store.PostgreSQL.Events.Concurrency

Description

This module implements optimistic concurrency control for the PostgreSQL backend by validating version expectations before event insertion.

Version checks use row-level locking to ensure consistency while minimizing contention between concurrent writers to different streams.

Synopsis

Documentation

checkVersions :: forall (t :: Type -> Type). Map StreamId (StreamWrite t SomeLatestEvent SQLStore) -> Transaction (Maybe (ConsistencyErrorInfo SQLStore)) Source #

Validate version expectations for all event batches.

Acquires row-level locks on affected streams and checks that each stream's current version matches the expected version. Returns Nothing if all checks pass, or details of any mismatches.