Area: backend · Effort: M
What: Add optimistic locking to vault and deposit entities to detect and handle concurrent modification conflicts without using database locks.
Why: Without concurrency control, simultaneous deposit requests can exceed vault capacity or produce incorrect balance calculations due to race conditions.
Acceptance Criteria:
- Vault and deposit entities have a
version column managed by TypeORM @VersionColumn
- Concurrent modification throws an
OptimisticLockVersionMismatchError
- The error is caught and retried up to 3 times with jitter before returning a 409
- A test demonstrates that two concurrent deposits to a near-full vault are handled correctly
Hints:
- Add
@VersionColumn() version: number to entity classes
- Use TypeORM's
save(entity, { version: entity.version }) syntax
- Retry decorator:
@Retryable({ maxAttempts: 3, backOff: 100 })
Area: backend · Effort: M
What: Add optimistic locking to vault and deposit entities to detect and handle concurrent modification conflicts without using database locks.
Why: Without concurrency control, simultaneous deposit requests can exceed vault capacity or produce incorrect balance calculations due to race conditions.
Acceptance Criteria:
versioncolumn managed by TypeORM@VersionColumnOptimisticLockVersionMismatchErrorHints:
@VersionColumn() version: numberto entity classessave(entity, { version: entity.version })syntax@Retryable({ maxAttempts: 3, backOff: 100 })