Repository navigation
Conversation
A dropped node connection removed both nodes from the cluster right away, and nothing tried to reconnect. A lost connection now enters the reconnect grace period if cloudnet.max.node.disconnect.millis is greater than 0. The default (0) keeps the old behaviour. - only one reconnect attempt per node at a time - remove nodes stuck in syncing once the grace period expires - send the startup time on authorization, so a restart during the grace period is treated as a new node - remote service providers look up the current node channel on each call instead of keeping the one from registration - apply the reconnecting node's services during service sync - flush queued packets and re-publish local services after a plain authorization - re-select the head node when a node becomes ready again - read the grace period when NodeDisconnectHandler is created, not at class load, so tests can set it - don't track reconnect attempts for the local node - add Javadoc (@SInCE 4.0) to the new public methods in NodeDisconnectHandler
|
Hi, thanks for your PR. I will take a look, I will just need some more time. I also think that when we now try to properly fix it we will need to look into service sync issues this might introduce. |
Hi thank you. I am running this fix since a few weeks on my cloud instance. Till now i couldn't find a service sync issue. Is it know already or could it appear by this change? If you figure out anything let me now. Best regards |
|
Hi @0utplay, thanks for the heads-up. I went looking for the service sync issues you mentioned and tested them on a real two-node cluster. It ran this branch with a 60s grace period and only What works
What doesn't (reproduced)
The node that noticed the loss keeps an entry for a service that no longer exists on its peer. That entry can't be deleted and was still there minutes later. That node also never learns about the peer's new service. The other direction is fine. Why this happens:
There is also a smaller issue. In the symmetric case the sync logs an Not tested yet: three or more nodes, mixed versions, and packet loss between the drain and the channel switch (found by reading the code). Proposal
Does that match what you had in mind? |
A node that reconnected before the other node noticed the lost connection was authorized like a new node, without the data sync of a reconnect. Changes made while the connection was down never reached the node that had not noticed the loss. - treat a reconnect with an unchanged startup time as a reconnect even if the node is still READY, by marking it disconnected first. This only applies if a grace period is configured and the node sends its startup time, other nodes are authorized as before - read the sync data of the authorization response the way it is written. It is written as a nullable object but was read as a plain data buf, so the presence marker was taken as the size and the whole sync was dropped - don't write the services of the local node during the service sync. The local node is the authority over its own services: outdated remote data no longer tries to re-register a removed service (which failed with a NullPointerException) or overwrite a known one
- a ready node that reconnects with the same startup time starts a reconnect. Nodes without a grace period, without a startup time or without a previous session are authorized as before, and a restarted node still joins as a new node - the sync data of a reconnect authorization response reaches the data sync registry. The test uses the real packet, so it fails if the data is read differently than it is written
Motivation
When the connection between two nodes dropped, even for a moment, both nodes removed each
other from the cluster immediately and never tried to reconnect. The cluster stayed split
until a node was restarted, and each node continued as its own head node. This happens
more often with nodes in different datacenters and with more nodes in the cluster.
The reconnect grace period (
cloudnet.max.node.disconnect.millis) only applied to nodesthat stopped sending updates while their socket stayed open. When the socket itself was
closed, the channel close handlers called
NodeServer#close()directly. The reconnecthandshake had also never really been used, and it had several problems once it was.
Modification
cloudnet.max.node.disconnect.millisis greater than0, instead of removing the nodedirectly. The default of
0keeps the previous behaviour.connections can break the reconnect handshake. Nodes stuck in the syncing state after
an interrupted reconnect are removed once the grace period expires.
restart during the grace period and let the node join as a newly started node, instead
of reconnecting it into its old session (which failed with an NullPointerException in
AuthorizationResponsePacketListener). Nodes on older versions don't send it, andolder nodes ignore it, so mixed versions keep working.
instead of keeping the channel that was used during registration. That channel is
closed after a reconnect.
Before, they were skipped because the node wasn't
available()yet.services are re-published to the other node.
the same head node.
NodeDisconnectHandleris created, so it can be set intests.
NodeDisconnectHandler,NodeDisconnectTrackerTask,AuthorizationPacketListenerandAuthorizationResponsePacketListener.launcher.cnldescription ofcloudnet.max.node.disconnect.millis.Result
With a grace period configured, nodes reconnect after short network interruptions and
agree on the same head node afterwards. A node that restarts within the grace period
joins cleanly as a new node. If a node does not come back within the grace period, it is
removed like before. With the default setting, behaviour is unchanged.
Tested manually with two nodes (grace period 30s/60s):
ss -K): before, both nodes dropped each other and neverreconnected. Now both are
READYagain within a few seconds, with the same head node.now matches on both nodes (before, each node showed itself as head).
the node joins as a new node without errors.
0: same behaviour as before.Other context
Known limitations:
node is restarted, like before.
DefaultCloudServiceManagerare not covered by unittests, as the class needs most of the node to be constructed.
Tests:
https://hastebin.baxnetzwerk.de/ct-Z4gFrfyk
With
cloudnet.max.node.disconnect.millisset to 60.000:https://hastebin.baxnetzwerk.de/dzvj7KguKXk
With
cloudnet.max.node.disconnect.millisset to 0 or default:https://hastebin.baxnetzwerk.de/Bz+rvVdSEei
(the links are available for 1 year.)
Fixes #1897