In RemoveReplicaset we remove replicaset from idToReplicaset map and close its connection pool.
But in routeMap we may still have pointers to this replicaset. This looks like a buggy behavior.
The straightforward solution with replacing to nil all elements of routeMap, that hold this pointer, doesn't work.
Because there might be a discovering goroutine that holds an old value of idToReplicaset that is still in progress.
Therefore, we need a bit more smart solution.
In
RemoveReplicaset
we remove replicaset from idToReplicaset map and close its connection pool. But in routeMap we may still have pointers to this replicaset. This looks like a buggy behavior.The straightforward solution with replacing to nil all elements of routeMap, that hold this pointer, doesn't work. Because there might be a discovering goroutine that holds an old value of idToReplicaset that is still in progress. Therefore, we need a bit more smart solution.