Fix discarding explicit routes while removing duplicate ones

In the new clustering logic sometimes the TestStressChainedSolicitWorks test
would fail because the a node would end up with only implicit routes.
In this change, we stamp that one of the remotes is configured so that the nodes
at least have one explicit configured remote node.

Signed-off-by: Waldemar Quevedo <wally@nats.io>
This commit is contained in:
Waldemar Quevedo
2023-08-21 15:11:59 -07:00
parent 4886f1fec4
commit 673f654fbe

View File

@@ -2083,8 +2083,9 @@ func handleDuplicateRoute(remote, c *client, setNoReconnect bool) {
// removeRoute() now does the right thing of doing that only when
// the closed connection was an added route connection.
c.mu.Lock()
didSolict := c.route.didSolicit
didSolicit := c.route.didSolicit
url := c.route.url
rtype := c.route.routeType
if setNoReconnect {
c.flags.set(noReconnect)
}
@@ -2095,10 +2096,15 @@ func handleDuplicateRoute(remote, c *client, setNoReconnect bool) {
}
remote.mu.Lock()
if didSolict && !remote.route.didSolicit {
if didSolicit && !remote.route.didSolicit {
remote.route.didSolicit = true
remote.route.url = url
}
// The extra route might be an configured explicit route
// so keep the state that the remote was configured.
if rtype == Explicit {
remote.route.routeType = rtype
}
// This is to mitigate the issue where both sides add the route
// on the opposite connection, and therefore end-up with both
// connections being dropped.