Question

I have a document that logs a user journey within my site.

Mouse movements are stored as a subdocument of this document. I log mouse movements then periodically use $push to append to the subdocument array. From my initial readings on Mongo this seemed to be a sensible/efficient approach. Now I am not so sure.

I have recently been having some issues with my replica set -secondaries fall out of sync with the primary when I have spikes in usage. Looking at my oplog I noticed that there were lots of $set commands each containing the whole history of the user's mouse movements up to that point and it seems that Mongo is doing this expansion so that oplog records can be indepotant.

Believe it is related to this issue on JIRA https://jira.mongodb.org/browse/SERVER-9784

Have I interpreted this issue correctly? If so, seems like a very inefficient way to be propagating changes over the wire. Is there any way to get around the problem? Would I be better off separating out the mouse movements into individual tiny documents? Or could I get around the problem by using dynamic keys on the subdocument array (therefore avoiding the $push command).

Was it helpful?

Solution

Thanks to all for suggestions. Think I have got to the bottom of it now.

Looks like my problem is a bug.

Using $each in conjunction with $push in mongoDB is currently(v2.4.3) horrifically inefficient in replication terms. Have updated the related Jira issue to narrow the criteria.

https://jira.mongodb.org/browse/SERVER-9784

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top