Skip to content

setKeyspace defuncts connections on operation timeout #1037

Description

@dkropachev

Problem

Connection.setKeyspace handles ConnectionException before OperationTimedOutException:

} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof BusyConnectionException) {
throw keyspaceBusyException();
} else if (cause instanceof QueryValidationException) {
throw (QueryValidationException) cause;
} else if (cause instanceof ConnectionException) {
throw defunct((ConnectionException) cause);
} else if (cause instanceof OperationTimedOutException) {
// Rethrow so that the caller doesn't try to use the connection, but do not defunct as we
// don't want to mark down
logger.warn(
"Timeout while setting keyspace on {}. "
+ "This should not happen but is not critical (it will be retried)",
this);
throw new ConnectionException(endPoint, "Timeout while setting keyspace on connection");

OperationTimedOutException extends ConnectionException:

public class OperationTimedOutException extends ConnectionException {

The timeout branch is unreachable. A transient keyspace setup timeout defuncts the connection and signals host conviction, contrary to the intended handling.

Fix

Check OperationTimedOutException before generic ConnectionException. Add synchronous setKeyspace coverage asserting the connection remains usable.

Regression from #942.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions