132 karma · joined Mar 25, 2010 (16y ago) · 67 submissions
comment 13y ago · link · parent
comment 13y ago · link · parent
That said, it makes sense for this to be opt-in behavior rather than the default.
comment 14y ago · link · parent
By the way, if you (or anyone else for that matter) come up with useful benchmarks I'd love to get a copy of them at mathias@10gen.com. I have a few of my own, but I'd like to get some real-world workloads from the community to test potential optimizations against.
comment 14y ago · link · parent
comment 14y ago · link · parent
[1] To see an example of the difference this makes see http://blog.pythonisito.com/2011/12/mongodbs-write-lock.html
comment 14y ago · link · parent
[1] http://www.mongodb.org/display/DOCS/Updating#Updating-%24add...
comment 14y ago · link · parent
http://www.mongodb.org/display/DOCS/Geospatial+Indexing http://www.mongodb.org/display/DOCS/Geospatial+Haystack+Inde...
comment 15y ago · link · parent
comment 15y ago · link · parent
PS - It is important to note that the jslock is completely separate from the dblock and it is rare to hold both simultaneously. This means that if you are running multiple Map Reduces, one can be fetching or writing data to the DB while the other is processing the objects in JS.
comment 15y ago · link · parent
comment 15y ago · link · parent
As for safe-mode, the waiting that it does is always outside of the lock. It uses a cached datastructure that is protected by a secondary mutex so that it never has to interact with the global dbMutex. If you choose to wait for replication or journalling of your writes, that will block the connection and therefore your client thread so single-threaded tests will show much worse performance with the db mostly idle. If you use more client threads or asynchronous I/O connections you should see roughly identical throughput in aggregate (see mongostat) although much higher latencies compared with not waiting.
If you have any questions about this feel free to shoot me an email. Replace the _ with an @ and add a .com to my user name.
comment 15y ago · link · parent
comment 15y ago · link · parent
Unfortunately a lot of companies don't use today's compilers, but use many-year old versions. For example, Apple still ships gcc 4.2 which is over 4 years old now and supports none of these features.
comment 15y ago · link · parent
[1] http://www.amazon.com/Effective-Specific-Improve-Programs-De... (Make sure you get the latest edition, a lot has changed for the better)
comment 15y ago · link · parent
That said, shared_ptr isn't a solution to everything. Sometimes scoped_ptr (called unique_ptr in tr1) or intrusive_ptr is a better tool. Often if you don't want to share or transfer ownership, passing around a raw ptr or reference is even better and the only option if you want to work with embedded structs (but the newed memory should still be owned by some RAII smart pointer even if it gets passed around as a bare pointer)
comment 15y ago · link · parent
comment 15y ago · link · parent
comment 15y ago · link · parent
For example, in the canonical transaction example of Alice giving Bob $5 you could insert a document in the transactions collection that says Alice gave Bob $5. When you go to fetch Alice's pending balance you fetch her current document, then you fetch all pending transactions than she is involved in. Same for Bob and all other users. Then each night, you pull that days transactions and apply them to each user and update an "as of" field to make sure no transaction can ever be applied twice.
Now you could argue that this isn't fully consistent because it is possible for Alice to simultaneously give $5 to both Bob and Charlie even if she only has $7 in her account. However she will then have a pending balance of $-3 so it immediately reflects her current situation. This is similar to the real world example of overdrawing you checking account. If you wanted to, you could void one or both of those transactions if you never want to allow a user to go negative.
comment 15y ago · link · parent
[1] http://www.mongodb.org/display/DOCS/Why+Replica+Sets
[2] http://www.mongodb.org/display/DOCS/Verifying+Propagation+of...
[3] http://www.mongodb.org/display/DOCS/Journaling
[4] http://www.mongodb.org/display/DOCS/Replica+Sets+-+Priority
comment 15y ago · link · parent
Also, for anyone looking to embed MongoDB and who doesn't mind using C++ it is possible and rather easy. In fact some of our unit tests and all of our tools other than the shell already do this. See https://github.com/mongodb/mongo/blob/master/tools/tool.cpp#... for the details. The DBDirectClient class implements the full C++ driver interface but does all operations in-process. The downside is that unlike when using our drivers (which have no licensing impact on your code) when you embed mongodb within your application it becomes bound by AGPL.
PS- That is really impressive for a weekend project! You should get in touch with us at 10gen if you're looking for a new job.
comment 15y ago · link · parent
"A BSON ObjectID is a 12-byte value consisting of a 4-byte timestamp (seconds since epoch), a 3-byte machine id, a 2-byte process id, and a 3-byte counter. Note that the timestamp and counter fields must be stored big endian unlike the rest of BSON. This is because they are compared byte-by-byte and we want to ensure a mostly increasing order."
http://www.mongodb.org/display/DOCS/Object+IDs#ObjectIDs-BSO...
29.
Fun with MongoDB replica sets(engineering.foursquare.com ↗)
16 points · by mathias_10gen · 15y ago · discuss
comment 15y ago · link · parent