SERVER-10564 enable the plan cache

With this commit, the plan cache is fully enabled. The other changes are bug fixes in order to resolve issues exposed by turning on the cache.