eventstoredb

Optimistic locking by correlationId in event store


How do you achieve optimistic locking by correlationId in EventStoreDB? As I saw in the documentation revision/version is only supported per stream, and putting correlationId in the stream name is bad practice and should affect memory.

Edit: I'm trying to:

  1. Get events by correlationId
  2. Do a validation if next action is possible
  3. Write new event in same stream with same correlationId

I don't want to perform optimistic locking on entire stream because then the same logic will fail for different correlationId if I do step one at the same time.

This seem to me as common feature of event sourcing that event store should support.


Solution

  • You can indeed only do optimistic concurrency check on stream level ( i.e not on a derived stream created by the system projections)