-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Incorrect leader elected #196
Comments
The weights for the leader election are more guidelines than hard rules. When connecting instances together the leader is chosen by the following logic:
During an election each instance just submits a vote for the node that has the highest weight from the ones that it knows of locally. Applying this to your scenario, I suspect that your bedroom node was already running and elected itself as leader when livingroom connected. As a quick fix you can try to shutdown both instances, then start livingroom. Once that's done you can start bedroom. Both should now have livingroom as the leader. |
Ahh, thanks for the explanation. The issue for me is that the raspberry pi doesn't have the best connection (ssh is really slow) so I suspect that I'm not getting updates when it's the leader. I can force livingroom to be the leader by restarting the pi but my livingroom server also restarts from time to time (updates) so it would be nice if it didn't lose its leadership position because of that. Would it make sense to change the propofol and elect a leader every time a node joins a cluster? |
The issue with that would likely be random state changes, as an instance starts with an empty state. Once an instance is elected as leader it will force the entities to match its own local state - if the state hasn't regenerated to the right level yet on the instance you will see random blips of wrong states with the restarts. Aside from that, if your instance reconnects within |
Couldn't there be some initialization protocol where a new node that becomes the new leader initializes its state before taking over as the leader? The issue in my case is that the bedroom node has bad wifi and so I don't want it to be the leader. I understand that my use case is maybe not the target use case so feel free to close this issue as |
There probably could be - and at the very least we should handle these kinda scenarios better. I'll keep this open for tracking. Maybe I can think of a good solution! |
There hasn't been any activity on this issue recently. In an effort to provide a better overview of current issues we automatically clean some of the old ones. Many of them may already be resolved in newer versions of room-assistant. |
Please don't close this issue. |
I believe the |
Describe the bug
I have a cluster with two nodes and the wrong node gets elected as leader.
The main node is
livingroom
with weight 100. I also have a second nodebedroom
that should not be the leader. However, as you can see in the logs below, the bedroom got elected as the leader.Relevant logs
Relevant configuration
Paste the relevant parts of your configuration below.
living room
bedroom
Expected behavior
I would expect the livingroom node to be the leader.
Environment
The text was updated successfully, but these errors were encountered: