Comments (4)
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.
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:
- Commit changes to persistence engine (OK!)
(OptimisticPipelineHook.PostCommit)
DispatchSchedulerPipelineHook.PostCommit
(too soon)OptimisticEventStream.PopulateStream
To:
- Commit changes to persistence engine (OK!)
(OptimisticPipelineHook.PostCommit)
OptimisticEventStream.PopulateStream
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:
- Commit changes to persistence engine (OK!) [thread a]
(OptimisticPipelineHook.PostCommit)
[thread a]DispatchSchedulerPipelineHook.PostCommit
(too soon) [thread a]- Receive new command in [thread b]
- 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]
OptimisticEventStream.PopulateStream
[thread a]
from neventstore.
Sample, ugly fix: https://github.com/haf/EventStore/compare/feature%2Fmemstream
from neventstore.
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)
- Paging over all events HOT 4
- Iterating over all streams HOT 2
- Docs out of date?
- Changelog clarification: Serialization/Data format changes between 5.2.0 and newer HOT 3
- Missing Firebird Sql as a Supported Persistence Engine HOT 2
- NEventStore constraint failed with MySql 8.x (works with 5.7) HOT 2
- .Net 5 support
- Upgrading from NES5 to NES8 - what happened to commit dispatchers? HOT 1
- CosmosDB Persistence HOT 1
- Typo on neventstore.org page
- Add net6.0 support
- Bring back intellisense and documentation support
- Refactor IPipelineHook: separate it in multiple interfaces (ISelectionPipelineHook, ICommitPipelineHook)?
- Storage Trade-offs? HOT 2
- Provide a way to invalidate the internal cache of the OptimisticPipelineHook
- Allow upcasting of an event to multiple streams
- Optimize Target Frameworks: netstandard2.0, net462
- NuGet Package: add ReadMe and License
- Quick Start is not that useful and is out of date
- Async Polling Client?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neventstore.