Skip to content

Commit

Permalink
[CONJ-613] ensuring that connection using "replication" Parameters do…
Browse files Browse the repository at this point in the history
…esn't fail when no slave is available
  • Loading branch information
rusher committed May 24, 2018
1 parent 9ef7178 commit 8fc2cf6
Showing 1 changed file with 19 additions and 4 deletions.
Expand Up @@ -268,10 +268,25 @@ public long getServerThreadId() {
}

protected void checkInitialConnection(SQLException queryException) throws SQLException {
if (this.secondaryProtocol == null || !this.secondaryProtocol.isConnected()) {
setSecondaryHostFail();
} else {
resetSecondaryFailoverData();
Protocol waitingProtocol;
if (isSecondaryHostFail()) {
if ((waitingProtocol = waitNewSecondaryProtocol.getAndSet(null)) != null) {
this.secondaryProtocol = waitingProtocol;
if (urlParser.getOptions().assureReadOnly) {
setSessionReadOnly(true, this.secondaryProtocol);
}
if (currentReadOnlyAsked) currentProtocol = waitingProtocol;
resetSecondaryFailoverData();
}
}
if (isMasterHostFail()) {
if ((waitingProtocol = waitNewMasterProtocol.getAndSet(null)) != null) {
this.masterProtocol = waitingProtocol;
if (!currentReadOnlyAsked || isSecondaryHostFail()) {
currentProtocol = waitingProtocol;
}
resetMasterFailoverData();
}
}

if (this.masterProtocol == null || !this.masterProtocol.isConnected()) {
Expand Down

0 comments on commit 8fc2cf6

Please sign in to comment.