News for hackers. Stuff that matters.
Re:Why I'm So Happy About MongoDB by matan_a on Tuesday December 13, 2011 @11:21AM (#3347950)
I've been developing using MongoDB for a few months now and the thing that always comes back to me as missing is the need to group a set of actions so that they perform atomically. It's not exactly meaning i need transactions (i don't care about the commit/rollback part), just need the need to say - hey server, do X, Y, and Z as a batch so that another thread won't do something in the middle of that.

The general consensus on this is to structure your data so that it encapsulates your business needs in one document structure (which is atomic on changes), but i find it hard to always conform to in the real world.

So now i have to use zookeeper (memcached also works) to setup global locks on those specific batch update actions. I guess it's a small price to pay right? Right?

Re:Why I'm So Happy About MongoDB by veesahni on Tuesday December 13, 2011 @11:57AM (#3348127)
I believe MongoDB's server side functions allow you to create an atomic grouping of operations.. i.e. store a function and call it by db.eval()

See the following:

http://www.mongodb.org/display/DOCS/Server-side+Code+Executi... http://www.mongodb.org/display/DOCS/Server-side+Code+Executi...

Re:Why I'm So Happy About MongoDB by matan_a on Tuesday December 13, 2011 @12:26PM (#3348283)
Thanks for the suggestion, but still not ideal. It performs a global lock on the DB which would block all operations while it computes.
Re:Why I'm So Happy About MongoDB by stonemetal on Tuesday December 13, 2011 @01:33PM (#3348595)
I tend to use a lock just long enough to write a transaction document. After you get the transaction captured in a document you can go back and fix up the primary documents without a lock.