Personal technical blog of Aristarkh Zagorodnikov. Topics covered include (or at least plan to include) C++, C#, MongoDB, NGINX and other development technologies.
MongoDB connection affinity
When using MongoDB via C# driver (might apply to other drivers as well), if you're queuing modifications (i.e. using SafeMode.False) and expect to see the first modification done before the second (I was Remove-ing one item and Insert-ing another one with the same key), never forget to use the same connection (via MongoDatabase.RequestStart), unless would like to get unpleasant surprises, like unexplainable intermittent failures that only occur when your application gets enough load. While after having a close look it is obvious that write ordering is not preserved by default, it wasn't obvious enough when I wrote the initial code for our message queue.
Subscribe to: Post Comments (Atom)
Post a Comment