diff --git a/server/client.go b/server/client.go index 57fd1901..b90c6eff 100644 --- a/server/client.go +++ b/server/client.go @@ -894,10 +894,7 @@ func (c *client) readLoop() { // Check the per-account-cache for closed subscriptions cpacc := c.kind == ROUTER || c.kind == GATEWAY // Last per-account-cache check for closed subscriptions - now := time.Now() - lpacc := now - // Update our notion of when we started. Useful for better initial RTT estimation. - c.start = now + lpacc := time.Now() c.mu.Unlock() defer func() { diff --git a/server/routes_test.go b/server/routes_test.go index db9a68eb..344906f1 100644 --- a/server/routes_test.go +++ b/server/routes_test.go @@ -753,6 +753,7 @@ func wait(ch chan bool) error { func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) { s1Opts := DefaultOptions() + s1Opts.ServerName = "A" s1Opts.Host = "127.0.0.1" s1Opts.Port = 4222 s1Opts.Cluster.Host = "127.0.0.1" @@ -771,6 +772,7 @@ func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) { chch <- true } nc, err := nats.Connect(s1Url, + nats.ReconnectWait(50*time.Millisecond), nats.ReconnectHandler(connHandler), nats.DiscoveredServersHandler(func(_ *nats.Conn) { ch <- true @@ -780,6 +782,7 @@ func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) { } s2Opts := DefaultOptions() + s2Opts.ServerName = "B" s2Opts.Host = "127.0.0.1" s2Opts.Port = s1Opts.Port + 1 s2Opts.Cluster.Host = "127.0.0.1" @@ -794,6 +797,7 @@ func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) { } checkPool := func(expected []string) { + t.Helper() // Don't use discovered here, but Servers to have the full list. // Also, there may be cases where the mesh is not formed yet, // so try again on failure. @@ -822,6 +826,7 @@ func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) { checkPool([]string{s1Url, s2Url}) s3Opts := DefaultOptions() + s3Opts.ServerName = "C" s3Opts.Host = "127.0.0.1" s3Opts.Port = s2Opts.Port + 1 s3Opts.Cluster.Host = "127.0.0.1"