Thank you for comments.
Right now we do use server timestamps by sending an empty timestamp in
ts field, and letting the server fill in the timestamp (as described
above).
And this approach is the most concurrency friendly as I can think of.
On 25 окт, 23:14, Alvin Richards <
al...@10gen.com> wrote:
> So a couple of thoughts
>
> 1. To get the servertime, you can do this using db.eval
>
> > myfunc = function(x){ return new Date(); };
> > servertime = db.eval( myfunc) ;
As far as I know db.eval blocks other operations and will be a bootle
neck in updates heavy scenario.
>
> 2. Process the events
> Yes your scheme would work, but bear in mind any concurrency. For
> example, what if you need two threads to process the updates, you will
> then need to coordinate what is being worked on by the two threads
> etc.
Our scheme allows to have many consumers of updates. Actually we have
many instances of Solr and other external update handlers, not just
one.
Every handler just remembers the last timestamp, and next time it
polls for updates with a query
db.mycoll.find({ ts : { $gt : last_ts } }).sort({ ts : 1 })
So this way we can have multible external processes keeping in sync
with the documents collection.
> 3. Tailable cursors
>
> If you track the update events in a collection, then you can use a
> tailable cursor to get these changes as they happen. Restriction is
> that you need to use a capped collection, so you will need to size
> this correctly so that you do not loose events before they are
> processed
>
>
http://www.mongodb.org/display/DOCS/Tailable+Cursors
Yes, it's a possible solution. But i think timestamps is easier, cause
you don't need to join update event with documents to process the
update.