|
29 | 29 | import com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures; |
30 | 30 | import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting; |
31 | 31 | import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap; |
32 | | -import com.datastax.oss.protocol.internal.Message; |
33 | 32 | import com.datastax.oss.protocol.internal.ProtocolConstants; |
| 33 | +import com.datastax.oss.protocol.internal.response.Error; |
34 | 34 | import edu.umd.cs.findbugs.annotations.NonNull; |
35 | 35 | import java.net.InetAddress; |
36 | 36 | import java.net.InetSocketAddress; |
@@ -170,15 +170,16 @@ public CompletionStage<Iterable<NodeInfo>> refreshNodeList() { |
170 | 170 | peersV2Query.whenComplete( |
171 | 171 | (r, t) -> { |
172 | 172 | 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. |
182 | 183 | CompletableFutures.completeFrom( |
183 | 184 | query(channel, "SELECT * FROM system.peers"), peersQuery); |
184 | 185 | return; |
|
0 commit comments