-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
test timeout in TestReconnect2 #1208
Comments
The problem here is the following: We have two hosts that are connected by a single TCP connection (the failure doesn't happen when using QUIC). When this connection is closed on the first host, in the vast majority of cases, the second host notices this quite quickly (the TCP connection closed, or rather, reset). Occasionally, the second host doesn't notice that the connection is closed though. Minimal reproducer: func TestConnectHang(t *testing.T) {
h1, err := bhost.NewHost(swarmt.GenSwarm(t, swarmt.OptDisableQUIC), nil)
require.NoError(t, err)
h2, err := bhost.NewHost(swarmt.GenSwarm(t, swarmt.OptDisableQUIC), nil)
require.NoError(t, err)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
require.NoError(t, h1.Connect(ctx, peer.AddrInfo{ID: h2.ID(), Addrs: h2.Addrs()}))
require.Len(t, h1.Network().Conns(), 1)
require.Len(t, h2.Network().Conns(), 1)
h2.SetStreamHandler(protocol.TestingID, func(str network.Stream) {
io.ReadAll(str)
})
str, err := h1.NewStream(ctx, h2.ID(), protocol.TestingID)
require.NoError(t, err)
_, err = str.Write([]byte("foobar"))
require.NoError(t, err)
require.NoError(t, str.CloseWrite())
fmt.Println(h1.Network().Conns()[0])
require.NoError(t, h1.Network().Conns()[0].Close())
require.Eventually(t, func() bool { return len(h1.Network().Conns()) == 0 }, 10*time.Second, 10*time.Millisecond)
require.Eventually(t, func() bool { return len(h2.Network().Conns()) == 0 }, 10*time.Second, 10*time.Millisecond)
} output (that's the last
The interesting thing is that both TCP RSTs are sent, so both connections should be closed. From a go routine dump it looks like the
|
Interestingly, when I implement the same reproducer with two |
Update: This only fails on OSX. Here's a reproducer that only uses standard library packages: https://gist.github.com/marten-seemann/176b6bfc7115cf3984eb6756f35252cf. |
The text was updated successfully, but these errors were encountered: