typesense / typesense/typesense
Cluster stuck with no leader after DR changes all node IPs (Raft references old addresses)
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 26.6k
- Forks
- 973
- Avg merge
- 18h 45m
- Merged PRs (30d)
- 4
Description
Description
During our Disaster Recovery (DR) process, all Typesense nodes change their IP addresses (e.g., from x.x.26.x to x.x.27.x). Once in the DR environment, we stop the Typesense service on each node and modify only the .ini file (specifically the nodes setting) to reference hostnames. However, Raft persists the old IPs in its logs/snapshots, causing the cluster to remain in a no-leader state after restart.
Steps to Reproduce
- Set up a multi-node cluster (e.g., 3 nodes in
x.x.26.x) in the primary data center, each referencing the others in thenodesconfig. - Trigger a DR failover so that all nodes come online in
x.x.27.x. - Stop the service on each node and edit the
.inito reference the new hostnames (or IPs). - Restart the service with the updated
.ini. Despite this, the Raft snapshots/logs still reference the old IPs, leaving the cluster without a leader.
Expected Behavior
- That updating
nodesin the.iniand restarting would allow the cluster to seamlessly transition to the new IP/hostname environment. - A supported method for Raft to remove or replace the old IP references when all nodes have changed addresses.
Actual Behavior
- Even after editing
.ini, Raft keeps the oldx.x.26.xIP addresses in its internal state. - Leader elections fail, and the cluster remains stuck with messages like:
WYYYYMMDD HH:MM:SS raft_server.cpp:734] Multi-node with no leader: refusing to reset peers. WYYYYMMDD HH:MM:SS node.cpp:1589] node default_group:x.x.27.x:8107:443 can't do pre_vote as it is not in x.x.26.11:8107:443, x.x.26.12:8107:443, x.x.26.13:8107:443
Troubleshooting Attempts
- Removing/Editing Raft files (e.g.,
raft_meta,log_inprogress_...):- Often leads to data inconsistencies or collection loss because the Raft state no longer matches the on-disk data.
- Switching to hostnames in
.ini:- Does not help if the Raft log was already populated with old IP references, as the log seems to override the new configs.
- Partial re-bootstrapping:
- Requires carefully stopping and restarting nodes in a new configuration, which risks data integrity if not done meticulously.
Current Workaround
Our current workaround after DR is:
- Stop the service on each node.
- Change
nodesin each node’s.inito list only the local hostname. - Start each node, creating three separate single-node clusters.
- Stop the service again on each node.
- Re-edit
nodesto include all three hostnames (the full cluster) in each node’s.ini. - Start the service again.
This procedure brings the cluster back, but it is cumbersome and seems more like a workaround than a robust solution.
Notes / Request for Guidance
While this process works for now, it feels like a temporary fix for DR scenarios. We would greatly appreciate any official guidance or more robust methods to handle full IP/hostname changes without multiple restarts or risking data loss. If there are other ideas, commands, or best practices for updating or cleaning up Raft references in a safer manner, we are open to suggestions.
Thank you for your assistance and for all your work on Typesense!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported messages in raft_server.cpp:734 and node.cpp:1589, then inspect the raft_meta and log_inprogress files mentioned in the troubleshooting notes. Trace how persisted Raft peer addresses interact with the nodes setting during restart. Done should be a supported, data-safe recovery or reconfiguration path for changing every node's address, with coverage for the described DR scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100