forked from scylladb/gocql
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reconnecting to cluster (gocql#1555)
After merging gocql#1369 it could happen that after losing connection to a host, it is not reconnected. That could happen in the following case: 1. We lose connection to a host. 2. We receive UP event for the host, the host is marked as UP even though we don't have active connections to it. 3. We don't reconnect to the host in reconnectDownedHosts because it's marked as UP already. In PR 1369 we intended to change the host states so that a host is marked as UP only after we have some connection to it. However, we also removed the call to fill the pool on UP event in case the host already existed. This commit adds the call to fill the pool back to handleNodeUp. We introduce handleNodeConnected for marking the host as up, so that handleNodeUp handles only the UP event and the responsibilities are clear. Control connection is tried to be reconnected every second after it is lost. Before PR 1369, after establishing a control connection to a host, we triggered pool refill for the same host. PR 1369 removed this behaviour so that it is possible to wait for the connection to be added to the pool in Session.init (and not mark the host UP if we have only control connection. This means that it could take up to cfg.ReconnectInterval after estabilishing control connection to have some usable host in the pool to service user queries after PR 1369. To restore the old behavior, we add back triggering of pool refill after control connection is connected. We can only do so after the session is initialized, so that we don't the interfere with initialization code in Session.init. Related gocql#915 Co-Authored-By: Ivan Boyarkin <ivan.boyarkin@kiwi.com>
- Loading branch information
1 parent
558dfae
commit 312a614
Showing
5 changed files
with
56 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters