ruby - Querying delayed_jobs in Mongo blocks while map reduce is running -


i'm using ruby's delayed_job_mongoid gem queue map/reduce jobs in background. jobs process fine, completing in minute.

now i'm trying query status of jobs while processing, i'm finding query perform on delayed_jobs table while map/reduce running hangs there, blocking until of jobs have finished.

so example, if execute db.delayed_jobs.find() while map/reduce running, sits there until every last job finished, displays contents of table (which empty point). it's if entire table getting locked while jobs running. isn't expect.

i've checked , i'm not running out of database connections. know what's going on?

this limitation of how mongodb's map reduce works @ moment. time being, mongodb still has db level locking , map reduce jobs in particular take out both read , write lock unless job explicitly non-atomic.

you can read more how make mapreduce command non-atomic here (caveat: available in mongodb v2.2+).

if nonatomic true, post-processing step prevent mongodb locking database; however, other clients able read intermediate states of output collection. otherwise map reduce operation must lock database during post-processing.

mongodb's aggregation framework bit more performant map reduce. however, new , can't quite same things yet. if can accomplish same task via aggregation framework i'd recommend using instead.

for reference, here's list of operation types , kinds of locks each operation requires:

http://docs.mongodb.org/manual/faq/concurrency/#which-operations-lock-the-database


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -