Git Product home page Git Product logo

Comments (4)

joliver avatar joliver commented on July 22, 2024

Perhaps I'm not quite following what you're saying. In looking at the code--OptimisticEventStore.cs line 98, I'm first pushing the "attempt" to storage. Following a successful commit of the attempt, I push the "commit" into the dispatch scheduler which one of the pipeline hooks.

I guess my question is, what is the exact problem you're experiencing and are you getting an exception?

from neventstore.

haf avatar haf commented on July 22, 2024

I think you should do precisely what you described in the future as well, but move the call to (:OptimisticEventStream).PopulateStream(StreamRevision+1, attempt.StreamRevision, new[]{ attempt }); in OptimisticEventStream.cs:152 to before the dispatch:

Now:

  1. Commit changes to persistence engine (OK!)
  2. (OptimisticPipelineHook.PostCommit)
  3. DispatchSchedulerPipelineHook.PostCommit (too soon)
  4. OptimisticEventStream.PopulateStream

To:

  1. Commit changes to persistence engine (OK!)
  2. (OptimisticPipelineHook.PostCommit)
  3. OptimisticEventStream.PopulateStream
  4. DispatchSchedulerPipelineHook.PostCommit

The problem is that I'm using request-reply right now, the reply being the event. When I get that one event, I have a command I wish to send directly afterwards, which actually leads to this 'observable' execution:

  1. Commit changes to persistence engine (OK!) [thread a]
  2. (OptimisticPipelineHook.PostCommit) [thread a]
  3. DispatchSchedulerPipelineHook.PostCommit (too soon) [thread a]
  4. Receive new command in [thread b]
  5. Thread reads OptimisticEventStream from dictionary Guid->Stream, finds this particular stream. Stream is yet to be populated, so it contains no events even though both dispatch has been sent and database written. [thread b]
  6. OptimisticEventStream.PopulateStream [thread a]

from neventstore.

haf avatar haf commented on July 22, 2024

Sample, ugly fix: https://github.com/haf/EventStore/compare/feature%2Fmemstream

from neventstore.

joliver avatar joliver commented on July 22, 2024

After researching exactly why this is happening, it's because the OptimisticEvenStream is designed to be single threaded, much like NHibernate's ISession or LINQ to SQL's DataContext. You'll notice this in the XML code comments for IEventStream.cs. The behavior of sharing across threads is undefined, which is exactly what you're experiencing.

from neventstore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.