Skip to content

Commit

Permalink
Ninja-follow-up to CASSANDRA-15727 (move code slightly)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamaleksey committed May 15, 2020
1 parent 0110311 commit 17caa28
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/java/org/apache/cassandra/net/OutboundConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1084,25 +1084,7 @@ void onFailure(Throwable cause)
if (hasPending())
{
Promise<Result<MessagingSuccess>> result = new AsyncPromise<>(eventLoop);
state = new Connecting(state.disconnected(),
result,
eventLoop.schedule(() ->
{
// Re-evaluate messagingVersion before re-attempting the connection in case
// endpointToVersion were updated. This happens if the outbound connection
// is made before the endpointToVersion table is initially constructed or out
// of date (e.g. if outbound connections are established for gossip
// as a result of an inbound connection) and can result in the wrong outbound
// port being selected if configured with enable_legacy_ssl_storage_port=true.
int maybeUpdatedVersion = template.endpointToVersion().get(template.to);
if (maybeUpdatedVersion != messagingVersion)
{
logger.trace("Endpoint version changed from {} to {} since connection initialized, updating.",
messagingVersion, maybeUpdatedVersion);
messagingVersion = maybeUpdatedVersion;
}
attempt(result);
}, max(100, retryRateMillis), MILLISECONDS));
state = new Connecting(state.disconnected(), result, eventLoop.schedule(() -> attempt(result), max(100, retryRateMillis), MILLISECONDS));
retryRateMillis = min(1000, retryRateMillis * 2);
}
else
Expand Down Expand Up @@ -1194,6 +1176,22 @@ private void attempt(Promise<Result<MessagingSuccess>> result)
{
++connectionAttempts;

/*
* Re-evaluate messagingVersion before re-attempting the connection in case
* endpointToVersion were updated. This happens if the outbound connection
* is made before the endpointToVersion table is initially constructed or out
* of date (e.g. if outbound connections are established for gossip
* as a result of an inbound connection) and can result in the wrong outbound
* port being selected if configured with enable_legacy_ssl_storage_port=true.
*/
int knownMessagingVersion = messagingVersion();
if (knownMessagingVersion != messagingVersion)
{
logger.trace("Endpoint version changed from {} to {} since connection initialized, updating.",
messagingVersion, knownMessagingVersion);
messagingVersion = knownMessagingVersion;
}

settings = template;
if (messagingVersion > settings.acceptVersions.max)
messagingVersion = settings.acceptVersions.max;
Expand Down

0 comments on commit 17caa28

Please sign in to comment.