Skip to content

Optimistic concurrency control by NES and NeventStore+SQL #42

@lees-oz

Description

@lees-oz

Hi there,
I've noticed that when the stream is commited, NES performs a read first to detect concurrency:

using (IEventStream eventStream = this._eventStore.OpenStream(bucketId, id, version, int.MaxValue))
    {
        EventStoreAdapter.Logger.Debug("Opened stream has StreamRevision {0}", (object) eventStream.StreamRevision);
        if (version != eventStream.StreamRevision && Transaction.Current != (Transaction) null)
        { 
            throw new ConflictingCommandException

Still there's a possibility for concurrency issue this way (result of OpenStream becomes stale immediately). I am using NEventStore with SQL persistence and the consistency of event stream is guaranteed by the database (PK on bucket, streamId and version). So the OpenStream looks like a redundant action in that case for me.
Please comment on that, thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions