When running the new, 2.0+ compact command on a collection on a MongoDB shard, the documentation says that commands are blocked while the compact is running. My question is, what exactly is blocked? Commands against that collection on that shard only? All commands to that collection across the cluster? All operations, regardless of collection on that shard?
So on and so forth....
Anyone know?
I would think that it's just commands against that collection on that shard since compacting a collection on one shard should, in theory, be independent of other shards, hence the point of sharding.
Thanks, Justin
Typically you run the compact on a secondary, since compaction is per node, not per-collection in the cluster. While running, the node is put into a state of recovering. As such it is not available to handle any reads or writes. You can see that in rs.status(). Once that secondary is complete, you move onto your next secondary. If you have done all the secondaries, you step down your master (causing one of the newly compacted secondaries to take over as master) & then run the compact on the now secondary (previous master).
I'm not even sure you can run compaction thru mongos as it should only be run on a mongod.