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(cluster): should remove the master if it's not node in the cluster #2643

Merged

Conversation

git-hulk
Copy link
Member

@git-hulk git-hulk commented Nov 3, 2024

Currently, the replica won't remove the master replication
while it's not a node in the cluster, which is an unexpected behavior
for the living master node in the cluster.

This fixes #2618.

Currently, the replica won't remove the master replication while it's
not a node in the clsuter, which an unexpcted behavior for the living
master node in the cluster.
@mapleFU
Copy link
Member

mapleFU commented Nov 3, 2024

When would "master is not a node in cluster" happens?

@git-hulk
Copy link
Member Author

git-hulk commented Nov 3, 2024

When would "master is not a node in cluster" happens?

oh, this issue is caused by the replica instead of the master was removed in the cluster, but its replication is still living.

Copy link

sonarqubecloud bot commented Nov 3, 2024

Comment on lines +206 to 209
return s.Prefixed("failed to set master-replica replication");
}

// Clear data of migrated slots
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should here check myself_ == nullptr and skip checking for:

  if (!migrated_slots_.empty()) {
    engine::Context ctx(srv_->storage);
    for (const auto &[slot, _] : migrated_slots_) {
      if (slots_nodes_[slot] != myself_) {
        auto s = srv_->slot_migrator->ClearKeysOfSlotRange(ctx, kDefaultNamespace, SlotRange::GetPoint(slot));
        if (!s.ok()) {
          LOG(ERROR) << "failed to clear data of migrated slots: " << s.ToString();
        }
      }
    }
  }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer keeping the previous behavior here since it should clear the keys of migrating slots once removed from the cluster.

@git-hulk git-hulk merged commit c701b98 into apache:unstable Nov 4, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

updating the topology information in kvrocks does not change the replication relationships
3 participants