In an event store a primary key on (stream_id, version) does this: the second writer of version 3 gets a unique violation.