Skip to content

Panic when an in flight request is canceled #36

@joao-r-reis

Description

@joao-r-reis

I was trying to reproduce a panic race condition in a different code when I ran into 2 different "panics" so I figured it would be best to report it here. In the code that reproduces this, we are opening and closing a lot of connections fast like this:

newCtx, _ := context.WithTimeout(ctx, time.Duration(rand.Intn(200)) * time.Millisecond)
tempCqlConn, err := cqlClient.ConnectAndInit(newCtx, primitive.ProtocolVersion4, 0)

But we are also sending a ton of requests concurrently like this (on another connection):

reqFrame3 := frame.NewFrame(primitive.ProtocolVersion4, 0, queryMsg)
inflightRequest3, err := cqlConn.Send(reqFrame3)
panic: send on closed channel

goroutine 242664 [running]:
github.com/datastax/go-cassandra-native-protocol/client.(*CqlClientConnection).Send(0xc0008a8480, 0xc0003c7420, 0x0, 0x0, 0xc000a97f60, 0xc001991e50)
	C:/Users/JoaoReis/go/pkg/mod/github.com/datastax/[email protected]/client/client.go:513 +0x26c
github.com/datastax/go-cassandra-native-protocol/client.(*CqlClientConnection).SendAndReceive(0xc0008a8480, 0xc0003c7420, 0xc0003c7420, 0x0, 0x0)
	C:/Users/JoaoReis/go/pkg/mod/github.com/datastax/[email protected]/client/client.go:546 +0x40
github.com/datastax/go-cassandra-native-protocol/client.(*CqlClientConnection).InitiateHandshake(0xc0008a8480, 0xe304, 0xc000983f80, 0xc0008a8480)
	C:/Users/JoaoReis/go/pkg/mod/github.com/datastax/[email protected]/client/handshake.go:62 +0x119
github.com/datastax/go-cassandra-native-protocol/client.(*CqlClient).ConnectAndInit(0xc001ac2120, 0xd6e3a0, 0xc000983f80, 0xe304, 0xc000983f80, 0xc000776ef0, 0xc0030cab00)
	C:/Users/JoaoReis/go/pkg/mod/github.com/datastax/[email protected]/client/client.go:136 +0x9c
github.com/riptano/cloud-gate/integration-tests.TestStressShutdown.func1.2(0xc0007066f0, 0xd6e320, 0xc00007f200, 0xc001ac2120, 0xc000a5be50)
	C:/Github/Riptano/cloud-gate/integration-tests/shutdown_test.go:191 +0x10c
created by github.com/riptano/cloud-gate/integration-tests.TestStressShutdown.func1
	C:/Github/Riptano/cloud-gate/integration-tests/shutdown_test.go:187 +0x55b
panic: send on closed channel

goroutine 283516 [running]:
github.com/datastax/go-cassandra-native-protocol/client.(*inFlightRequest).onFrameReceived(0xc001784b00, 0xc002c256e0, 0x0, 0x0)
	C:/Users/JoaoReis/go/pkg/mod/github.com/datastax/[email protected]/client/inflight.go:270 +0x127
github.com/datastax/go-cassandra-native-protocol/client.(*inFlightRequestsHandler).onIncomingFrameReceived(0xc000716e40, 0xc002c256e0, 0x1f, 0xc001fd5f20)
	C:/Users/JoaoReis/go/pkg/mod/github.com/datastax/[email protected]/client/inflight.go:122 +0x132
github.com/datastax/go-cassandra-native-protocol/client.(*CqlClientConnection).processIncomingFrame(0xc000184240, 0xc002c256e0, 0xc001ee0c40)
	C:/Users/JoaoReis/go/pkg/mod/github.com/datastax/[email protected]/client/client.go:428 +0x312
github.com/datastax/go-cassandra-native-protocol/client.(*CqlClientConnection).readFrame(0xc000184240, 0xd5ea20, 0xc001ee0c40, 0x0)
	C:/Users/JoaoReis/go/pkg/mod/github.com/datastax/[email protected]/client/client.go:374 +0xc7
github.com/datastax/go-cassandra-native-protocol/client.(*CqlClientConnection).incomingLoop.func1(0xc000184240)
	C:/Users/JoaoReis/go/pkg/mod/github.com/datastax/[email protected]/client/client.go:257 +0x85
created by github.com/datastax/go-cassandra-native-protocol/client.(*CqlClientConnection).incomingLoop
	C:/Users/JoaoReis/go/pkg/mod/github.com/datastax/[email protected]/client/client.go:249 +0xe4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions