|
Analysis:
There was a bug in getLastError in mongos that would make it call getLastError on shards that were not involved in the last write operation. This is caused by ClientConnections::checkVersions trying to connect to all shards, which in turn trigger the callback that adds the shard to the list of shards the getLastError should check. As a result, when the writeback listener calls getLastError, it can potentially end up with a getLastError object that is for multiple shards and the writeback listener does not properly parse this format (thus, bypassing the if( gle["code"].numberInt() == 9517) check) and can end up registering this gle to the _seenWritebacks data structure, which is exposed to the client connections calling getLastError.
SERVER-4532 fixed this by making sure that a shard will be added to the getLastError list only when we are explicitly creating a connection to it. To be exact, SERVER-4532 did this by moving the addShard call out of ShardingConnectionHook::onHandedOut to _ShardConnection::_init.
|