Concurrency Error¶
concurrency_error
¶
Error raised when an optimistic concurrency check detects a version conflict.
Indicates that an expected version does not match the current stored version
for an aggregate, meaning another writer committed a change between the
read and write phases of an operation.
ConcurrencyError
¶
Bases: EventStoreError[MetadataValueType]
Raised when an optimistic concurrency check fails.
Captures the conflicting aggregate identity and the expected
versus actual version numbers so callers can decide whether to
retry, reconcile, or fail the operation.
Attributes:
| Name | Type | Description |
|---|---|---|
aggregate_id |
The aggregate that experienced the conflict. |
|
expected_version |
The version the caller expected. |
|
actual_version |
The version currently stored. |
Example
Source code in src/forging_blocks/application/errors/concurrency_error.py
__init__(aggregate_id: UUID, expected_version: int, actual_version: int) -> None
¶
Initialise with the conflicting aggregate and version details.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aggregate_id
|
UUID
|
The identifier of the aggregate with the conflict. |
required |
expected_version
|
int
|
The version number the caller expected to find. |
required |
actual_version
|
int
|
The version number actually stored. |
required |