Multiple threads are using the same connection when the connection dies. All the threads race to restore the connection, potentially, reconnecting multiple times.
Solution
Put the connection behind a RwLock, acquire the writer lock, check if the connection is closed via is_closed method, if it is, reconnect. This way the reconnection happens at most once.
Problem
Multiple threads are using the same connection when the connection dies. All the threads race to restore the connection, potentially, reconnecting multiple times.
Solution
Put the connection behind a RwLock, acquire the writer lock, check if the connection is closed via
is_closed
method, if it is, reconnect. This way the reconnection happens at most once.