fix(cluster) : moved error port number on migration finish (#4776)

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2025-03-17 10:38:29 +02:00 committed by Roman Gershman
parent 0e56a09f70
commit 429ac6219b
No known key found for this signature in database
GPG key ID: F25B77EAF8AEBA7A
2 changed files with 9 additions and 2 deletions

View file

@ -327,7 +327,6 @@ bool ClusterConfig::IsMySlot(std::string_view key) const {
ClusterNodeInfo ClusterConfig::GetMasterNodeForSlot(SlotId id) const {
CHECK_LE(id, kMaxSlotNum) << "Requesting a non-existing slot id " << id;
for (const auto& shard : config_) {
if (shard.slot_ranges.Contains(id)) {
if (shard.master.id == my_id_) {
@ -335,7 +334,11 @@ ClusterNodeInfo ClusterConfig::GetMasterNodeForSlot(SlotId id) const {
// migrated
for (const auto& m : shard.migrations) {
if (m.slot_ranges.Contains(id)) {
return m.node_info;
for (const auto& shard : config_) {
if (shard.master.id == m.node_info.id) {
return shard.master;
}
}
}
}
}

View file

@ -2702,6 +2702,10 @@ async def test_migration_timeout_on_sync(df_factory: DflyInstanceFactory, df_see
await wait_for_status(nodes[0].admin_client, nodes[1].id, "FINISHED", 300)
await wait_for_status(nodes[1].admin_client, nodes[0].id, "FINISHED")
with pytest.raises(aioredis.ResponseError) as e_info:
await nodes[0].client.get("x")
assert f"MOVED 16287 127.0.0.1:{instances[1].port}" == str(e_info.value)
nodes[0].migrations = []
nodes[0].slots = []
nodes[1].slots = [(0, 16383)]