diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index 892bdc6..2a06add 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -1356,7 +1356,7 @@ future>> lo } future> load_peers() { - sstring req = sprint("SELECT peer FROM system.%s", PEERS); + sstring req = sprint("SELECT peer, tokens FROM system.%s", PEERS); return execute_cql(req).then([] (::shared_ptr cql_result) { std::vector ret; for (auto& row : *cql_result) { diff --git a/redis/commands/cluster_slots.cc b/redis/commands/cluster_slots.cc index 62886b6..6a511d2 100644 --- a/redis/commands/cluster_slots.cc +++ b/redis/commands/cluster_slots.cc @@ -38,13 +38,13 @@ future cluster_slots::execute(service::storage_proxy& proxy, db:: peers.emplace_back(local); auto slots_per_peer = REDIS_CLUSTER_SLOTS / peers.size(); std::vector> ret; + auto port = proxy.get_db().local().get_config().redis_transport_port(); size_t start = 0; for (auto& peer : peers) { auto end = start + slots_per_peer - 1; - if (end >= REDIS_CLUSTER_SLOTS) { + if (end >= (REDIS_CLUSTER_SLOTS - slots_per_peer)) { end = REDIS_CLUSTER_SLOTS - 1; } - auto port = proxy.get_db().local().get_config().redis_transport_port(); ret.emplace_back(std::tuple (start, end, to_bytes(peer.to_sstring()), uint16_t { port })); start = end + 1; }