The js test contains 3 tests running on the same cluster. The first test creates a hashed sharded collection. The second test will do the same with numInitialChunks at 500. At the time of the second test, the race will cause the moveChunk to fail and result in the chunks not being evenly distributed across the shards.
The race condition is as follows:
1. First test moves the minKey->maxKey chunk from shard0001 to shard0000.
2. fromShard (shard0001) tells toShard (shard0000) to commit and toShard sets the state to commit. The separate thread in toShard that is actually running the migration should see this change and terminate the thread. However, since this is on another thread, there is no guarantee on when this will exactly happen.
3. Second test tries to do a moveChunk from shard0001 to shard0000 but it fails because the shard0000 hasn't completely set the migration status to not active.
Note: this was causing the cause of this failure - http://buildlogs.mongodb.org/V2.4%20Linux%2064-bit/builds/27/test/sharding/hash_presplit.js
- is duplicated by
SERVER-9258 hash_presplit.js failure