简体   繁体   中英

MongoDB safe write issue

We have noticed this issue where data that is being "safely" written to the database, is not available few seconds later (say 2 seconds). Basically we do some safe writes to a collection (inside a web worker/request) and expect that data to be available from another process (Sidekiq workers).

Anyone know why this could be happening or has anyone seen similar behavior with MongoDB?

Ours is a Rails 3.2.9/Ruby 1.9.3/Mongo 2.0.4 application. We are using Mongoid as the ORM tool.

Here's how we doing safe writes:

account.safely.save!

Also, sharding is enabled for this collection and there is significant load on the server.

Following are the gems we use:

gem 'mongo', '1.6.1'
gem 'mongoid', '2.4.10'

You are experiencing this because there are per-connection queues. This is common when using connection pooling. From the same connection, you would have a consistent result.

Check out this Mongoid Issue on GitHub:

https://github.com/mongoid/mongoid/issues/2605

The milestone for this was Mongoid 3.0.15 -- you are using 2.4.10, which is pretty ancient

I'd recommend upgrading.. 3.1 is out already.


LOL - never mind - I just realize from your avatar that you opened that issue. :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM