Summary
Implement a DynamoDB-backed EventStore adapter (@dcb-es/event-store-dynamodb) that is fully DCB-compliant.
Approach
Pessimistic fine-grained locks + batch commit record.
- Fine-grained locks on
(eventType, tagValue) pairs — unrelated writes never conflict
- Atomic global sequence counter for ordering
- Batch commit record for crash-safe atomic visibility of large appends
- Small appends (≤~40 events) use a single
TransactWriteItems — zero lock overhead
- Large appends use lock-based flow with
BatchWriteItem — no size limit
Full technical design: packages/event-store-dynamodb/README.md
Key Design Decisions
- Why not optimistic watermarks? Type-level watermarks cause false conflicts between unrelated entities of the same type. Fine-grained watermarks blow the 100-item
TransactWriteItems limit on large batches.
- Why pessimistic locks? Fine-grained locks match the natural conflict boundary (same entity, same event type). In practice, conflicts are rare — most lock acquisitions succeed immediately. No transaction size limits on event writes.
- Crash safety: Every crash scenario is safe. Partial writes are invisible (PENDING batch). Stale locks expire via TTL.
Scope
Open Questions
- Tag query GSI strategy — depends on expected query patterns and tag cardinality
- Lock TTL value (likely 30-60s)
Query.all() optimisation to avoid global lock serialisation
Summary
Implement a DynamoDB-backed
EventStoreadapter (@dcb-es/event-store-dynamodb) that is fully DCB-compliant.Approach
Pessimistic fine-grained locks + batch commit record.
(eventType, tagValue)pairs — unrelated writes never conflictTransactWriteItems— zero lock overheadBatchWriteItem— no size limitFull technical design:
packages/event-store-dynamodb/README.mdKey Design Decisions
TransactWriteItemslimit on large batches.Scope
Open Questions
Query.all()optimisation to avoid global lock serialisation