Skip to content

Commit ce64618

Browse files
authored
Include ServerError in downgrade criteria from peers_v2 to peers (apache#1085)
The logic from JAVA-1388 dictates that the driver downgrades from system.peers_v2 to system.peers for node discovery if an INVALID_QUERY error is received. DSE 6.0.0 to 6.0.2 with search enabled inappropriately responds with a SERVER_ERROR with the message "Unknown keyspace/cf pair (system.peers_v2)". This commit handles this case specifically.
1 parent 8b37656 commit ce64618

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.datastax.driver.core.exceptions.DriverInternalError;
2424
import com.datastax.driver.core.exceptions.InvalidQueryException;
2525
import com.datastax.driver.core.exceptions.NoHostAvailableException;
26+
import com.datastax.driver.core.exceptions.ServerError;
2627
import com.datastax.driver.core.exceptions.UnsupportedProtocolVersionException;
2728
import com.datastax.driver.core.utils.MoreFutures;
2829
import com.datastax.driver.core.utils.MoreObjects;
@@ -707,9 +708,13 @@ public void onSuccess(ResultSet result) {
707708

708709
@Override
709710
public void onFailure(Throwable t) {
710-
// downgrade to system.peers if we get an invalid query as this indicates
711-
// the peers_v2 table does not exist.
712-
if (t instanceof InvalidQueryException) {
711+
// Downgrade to system.peers if we get an invalid query error as this indicates the
712+
// peers_v2 table does not exist.
713+
// Also downgrade on server error with a specific error message (DSE 6.0.0 to 6.0.2
714+
// with search enabled.
715+
if (t instanceof InvalidQueryException
716+
|| (t instanceof ServerError
717+
&& t.getMessage().contains("Unknown keyspace/cf pair (system.peers_v2)"))) {
713718
isPeersV2 = false;
714719
MoreFutures.propagateFuture(peersFuture, selectPeersFuture(connection));
715720
} else {

0 commit comments

Comments
 (0)