ruby on rails 3 - Benefit of $snapshot with Mongo? Is it okay to disable by default? -
this mongo page explains $snapshop command does, can explain why helpful, or whether it's wise disable default?
we're using mongomapper on rails 3.2.12, , mm seems enable snapshot on every query.
from this, should assume if there possibility of document being written , read in parallel, should not turn off $snapshot? or, more precisely, what's worst case? 1 user gets stale document?
no. not stale document. possibly same document twice, before update applied (not stale @ time) , after update applied.
this happen if update changes size of document, has moved physically in storage location. not happen in-place updates. happen if push big array.
also note depending on how @ this, may call first version of document "stale" (at time query finished), same applies other documents well: version accurate @ time individual document pulled query. not globally consistent across whole query.
and finally, $snapshot on, still have no guarantee not deleted documents , freshly inserted documents. , apparently, not work sharding either.
on plus side, documents (with snapshot on or off) internally consistent: version existed @ 1 time, not weird state in middle of update.
let's 1 query returns user , associated widgets. disabling $snapshot, same query return player document twice ... meaning return array contain 2 objects instead of one?
the same query cannot return "a user , widgets" if stored in 2 collections. there no joins in mongodb.
if widgets embedded user object, returned user, , represent consistent combination.
what happen here if query list of users have widgets or z, , updated user has widget have widget z (and moves document, because has grown now) user widget a, , second time widget , z.
if turn on snapshotting, won't happen (unless using sharding, snapshots apparently don't work). can still user concurrently being deleted, or not users being inserted while query running.
Comments
Post a Comment