PacktPublishing / Event-Driven-Architecture-in-Golang

Event-Driven Architecture in Golang, published by Packt
MIT License
336 stars 105 forks source link

Suggestion: add concurrency error on postgres event_store #16

Open dubyte opened 1 month ago

dubyte commented 1 month ago

What do you think about adding concurrency error. For context the event sourcing event has a version. But is not used to do optimistic locking.

Currently event store is just inserting pending events.

But as shown in CQRS page 43 listing 5.

we could query for the last version stored in posgres and if it does not match with the aggregate current version we return concurrency error and the user should load the aggragate and apply the events again.

matrixcloud commented 2 weeks ago

Hi @stackus Could you give some suggestions for the version increment which has a race condition?