Synchronize the whole getOrCreatePool method.

The ConnectionPools object should be refactored to not be a singleton to avoid global state.