RobertIndie commented on code in PR #1237:
URL: https://github.com/apache/pulsar-client-go/pull/1237#discussion_r1671958502
##########
pulsar/transaction_test.go:
##########
@@ -539,3 +540,56 @@ func TestAckChunkMessage(t *testing.T) {
require.Nil(t, err)
consumerShouldNotReceiveMessage(t, consumer)
}
+
+func TestTxnConnReconnect(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ topic := newTopicName()
+ _, cli := createTcClient(t)
+
+ txn, err := cli.NewTransaction(5 * time.Minute)
+ assert.NoError(t, err)
+
+ connections := cli.cnxPool.GetConnections()
+ for _, conn := range connections {
+ conn.Close()
+ }
+
+ err = txn.Commit(ctx)
+ assert.NoError(t, err)
+
+ txn, err = cli.NewTransaction(5 * time.Minute)
+ assert.NoError(t, err) // Assert that the transaction can be opened
after the connections are reconnected
+
+ // Start a goroutine to periodically close connections
+ go func() {
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-time.After(1 * time.Second):
+ connections := cli.cnxPool.GetConnections()
+ for _, conn := range connections {
+ conn.Close()
+ }
Review Comment:
`cli.cnxPool.Close()` will shutdown the entire connection pool which will
make the connection pool unuseable anymore. You can see that it close the
`closeCh` here:
https://github.com/apache/pulsar-client-go/blob/537be369d985f412a9ec27bca71501ea360c3e0e/pulsar/internal/connection_pool.go#L142
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]