5f67d9b451799c0dd777936cc0f4e5e73eb284e8 | Author: Ivan Boyarkin <19638942+mrVanboy@users.noreply.github.com>
| 2021-10-14 13:57:21+02:00
errors: Expose predefined raw protocol error codes
This commit is required to simplify the distinguishing between errors on
caller side especially for ones without distinct error type. The API of
the package already provides the exported RequestError interface which
returns the integer value of error code, but code itself were as
non-exported constants.
To achieve this the next changes has been done:
1. All predefined error codes has been renamed with pattern
s/err/ErrCode/
2. Every constant for error codes has been documented according to the
specification of the protocol v5 (section 8)
https://github.com/apache/cassandra/blob/7337fc0/doc/native_protocol_v5.spec
Fixes gocql/gocql#1335
312a614907c8d2e19f6b14aff16015436cb78423 | Author: Martin Sucha <martin.sucha@kiwi.com>
| 2021-04-30 17:23:32+02:00
Fix reconnecting to cluster (#1555)
After merging https://github.com/gocql/gocql/pull/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 https://github.com/gocql/gocql/issues/915
Co-Authored-By: Ivan Boyarkin <ivan.boyarkin@kiwi.com>