Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug : moved error port number on migration finish #4776

Merged
merged 2 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/server/cluster/cluster_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,18 @@ 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_) {
// The only reason why this function call and shard.master == my_id_ is the slot was
// 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;
}
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions tests/dragonfly/cluster_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2753,6 +2753,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)]
Expand Down
Loading