Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MongoSF: MongoDB Concurrency Internals in v2.2

MongoSF: MongoDB Concurrency Internals in v2.2

MongoSF: MongoDB Concurrency Internals in v2.2

mongodb

May 07, 2012
Tweet

More Decks by mongodb

Other Decks in Technology

Transcript

  1. Version #s vA.B.C Even B’s are stable Odd B’s are

    dev branch. Current stable = 2.0.x (e.g. v2.0.4) Current dev branch = 2.1.x (e.g. v2.1.1) (not for production) Once blessed, 2.1.x becomes v2.2.0 Thus 1.6 -> 1.8 1.8 -> 2.0 2.0 -> 2.2 2.2 -> 2.4 are similar magnitudes of change
  2. Two big changes in 2.2 1.  Eliminate the global reader/writer

    lock “Granularization” First step is db-level locks. 2.  PageFaultException architecture (yield lock on a page fault)
  3. Lock per db •  Reader/writer lock per database –  First

    step towards more granularity •  Global lock is still possible but now very rare (e.g. journaling locks the world for short intervals; the journal is shared by all dbs) •  More granularity should be fairly easy to add in the future – hard part is done –  Were places in code where assumptions were made about exclusivity when in a write lock; those are gone now
  4. Lock per db •  In v2.1.1+ sometimes two db’s are

    locked by the same thread – admin db for security info lookup – local db for replication (writing to the oplog)
  5. Structure of a write operation Lock(mydb); Do_write_operation(mydb); // slow Lock(local_database);

    Write_to_replication_oplog(); // fast Unlock(local_database); Unlock(mydb);
  6. Lock status can be inspected •  currentOp() •  serverStatus() • 

    MMS monitoring will evolve too to help with instrumentation of system status in this regard
  7. PageFaultException •  If on a write operation – Mutation has yet

    to occur – And we are going to page fault •  Then – Throw PageFaultException – While unlocked, touch the page – Retry the operation
  8. The Future •  More granularity •  Now that there is

    some, much easier •  Collection level for sure •  Document level locking (latching) – there are some nuances (btrees) – but at least directionally, yes
  9. Next : Thanks Please help us test the upcoming v2.2

    release by hammering the dev branch releases in your QA environment (i.e., v2.1.1).