Skip to content

Commit 575992a

Browse files
committed
Include SERVER_ERROR in downgrade criteria from peers_v2 to peers
1 parent 1a646b7 commit 575992a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

core/src/main/java/com/datastax/oss/driver/internal/core/metadata/DefaultTopologyMonitor.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures;
3030
import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
3131
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
32-
import com.datastax.oss.protocol.internal.Message;
3332
import com.datastax.oss.protocol.internal.ProtocolConstants;
33+
import com.datastax.oss.protocol.internal.response.Error;
3434
import edu.umd.cs.findbugs.annotations.NonNull;
3535
import java.net.InetAddress;
3636
import java.net.InetSocketAddress;
@@ -170,15 +170,16 @@ public CompletionStage<Iterable<NodeInfo>> refreshNodeList() {
170170
peersV2Query.whenComplete(
171171
(r, t) -> {
172172
if (t != null) {
173-
if (t instanceof UnexpectedResponseException) {
174-
UnexpectedResponseException e = (UnexpectedResponseException) t;
175-
Message message = e.message;
176-
if (message instanceof com.datastax.oss.protocol.internal.response.Error
177-
&& ((com.datastax.oss.protocol.internal.response.Error) message).code
178-
== ProtocolConstants.ErrorCode.INVALID) {
179-
// The query to system.peers_v2 failed, we should not attempt this query in the
180-
// future.
181-
this.isSchemaV2 = false;
173+
// If system.peers_v2 does not exist, downgrade to system.peers
174+
if (t instanceof UnexpectedResponseException
175+
&& ((UnexpectedResponseException) t).message instanceof Error) {
176+
Error error = (Error) ((UnexpectedResponseException) t).message;
177+
if (error.code == ProtocolConstants.ErrorCode.INVALID
178+
// Also downgrade on server error with a specific error message (DSE 6.0.0 to
179+
// 6.0.2 with search enabled)
180+
|| (error.code == ProtocolConstants.ErrorCode.SERVER_ERROR
181+
&& error.message.contains("Unknown keyspace/cf pair (system.peers_v2)"))) {
182+
this.isSchemaV2 = false; // We should not attempt this query in the future.
182183
CompletableFutures.completeFrom(
183184
query(channel, "SELECT * FROM system.peers"), peersQuery);
184185
return;

0 commit comments

Comments
 (0)