Skip to content

Commit 429ac62

Browse files
adiholdenromange
authored andcommitted
fix(cluster) : moved error port number on migration finish (#4776)
Signed-off-by: adi_holden <[email protected]>
1 parent 0e56a09 commit 429ac62

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/server/cluster/cluster_config.cc

+5-2
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,18 @@ bool ClusterConfig::IsMySlot(std::string_view key) const {
327327

328328
ClusterNodeInfo ClusterConfig::GetMasterNodeForSlot(SlotId id) const {
329329
CHECK_LE(id, kMaxSlotNum) << "Requesting a non-existing slot id " << id;
330-
331330
for (const auto& shard : config_) {
332331
if (shard.slot_ranges.Contains(id)) {
333332
if (shard.master.id == my_id_) {
334333
// The only reason why this function call and shard.master == my_id_ is the slot was
335334
// migrated
336335
for (const auto& m : shard.migrations) {
337336
if (m.slot_ranges.Contains(id)) {
338-
return m.node_info;
337+
for (const auto& shard : config_) {
338+
if (shard.master.id == m.node_info.id) {
339+
return shard.master;
340+
}
341+
}
339342
}
340343
}
341344
}

tests/dragonfly/cluster_test.py

+4
Original file line numberDiff line numberDiff line change
@@ -2702,6 +2702,10 @@ async def test_migration_timeout_on_sync(df_factory: DflyInstanceFactory, df_see
27022702
await wait_for_status(nodes[0].admin_client, nodes[1].id, "FINISHED", 300)
27032703
await wait_for_status(nodes[1].admin_client, nodes[0].id, "FINISHED")
27042704

2705+
with pytest.raises(aioredis.ResponseError) as e_info:
2706+
await nodes[0].client.get("x")
2707+
assert f"MOVED 16287 127.0.0.1:{instances[1].port}" == str(e_info.value)
2708+
27052709
nodes[0].migrations = []
27062710
nodes[0].slots = []
27072711
nodes[1].slots = [(0, 16383)]

0 commit comments

Comments
 (0)