NEventStore / NEventStore.Persistence.MongoDB

Mongo Persistence Engine for NEventStore
MIT License
22 stars 26 forks source link

UpdateStreamHeadAsync ObjectDisposedException #16

Closed radbradman closed 10 years ago

radbradman commented 10 years ago

I'm attempting to use MongoDB with NEventStore and running into an issue. I'm calling my stream updates with the IStoreEvents EventStore in a using statement (per request) as shown in the examples. However, I am very often getting an ObjectDisposedException thrown from UpdateStreamHeadAsync. I think since the operation runs with ThreadPool.QueueUserWorkItem, the object is often disposed of on the other thread before being able to execute the code in UpdateStreamHeadAsync.

Everything works fine when I remove the ThreadPool.QueueUserWorkItem and run the operation synchronously.

Is this a bug, or should I be handling disposal of the EventStore object differently than in the examples?

Thanks for the help! Brad

andreabalducci commented 10 years ago

IStoreEvents is thread-safe and can (should) be shared between threads. I'm evaluating an additional option to ServerSideOptimisticLoop for updating stream heads synchronously with the commit (will be a single roundtrip).

Check issue n. #10