You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/02/05 22:16:36 UTC
[GitHub] [pulsar-client-go] yuanweikang2020 opened a new issue #462: goroutine leak
yuanweikang2020 opened a new issue #462:
URL: https://github.com/apache/pulsar-client-go/issues/462
#### Expected behavior
```
func (c *connection) start() {
// Each connection gets its own goroutine that will
go func() {
if c.connect() {
if c.doHandshake() {
c.run()
} else {
c.changeState(connectionClosed)
}
} else {
c.changeState(connectionClosed)
}
}()
}
```
this code, If the pulsar doesn't work properly, it will cause a goroutine leak.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] rueian edited a comment on issue #462: goroutine leak
Posted by GitBox <gi...@apache.org>.
rueian edited a comment on issue #462:
URL: https://github.com/apache/pulsar-client-go/issues/462#issuecomment-780357151
There are also goroutine leaks in `consumer_partition.go` and `connection.go`
https://github.com/apache/pulsar-client-go/blob/25f3075176f853f5f09d89b3b625e0646432735f/pulsar/internal/connection.go#L333-L338
The `incomingRequestsCh` never closed, therefore this `failLeftRequestsWhenClose` will never exit.
https://github.com/apache/pulsar-client-go/blob/25f3075176f853f5f09d89b3b625e0646432735f/pulsar/consumer_partition.go#L786
The `eventsCh` never closed, there for this `runEventsLoop` will never exit.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] yuanweikang2020 commented on issue #462: goroutine leak
Posted by GitBox <gi...@apache.org>.
yuanweikang2020 commented on issue #462:
URL: https://github.com/apache/pulsar-client-go/issues/462#issuecomment-775637212
> thanks @yuanweikang2020 for this issue, can you provide more context how to reproduce or verify this issue?
when pulsar is failure, pulsar client reconnect
```
func (p *partitionProducer) runEventsLoop() {
for {
select {
case i := <-p.eventsChan:
switch v := i.(type) {
case *sendRequest:
p.internalSend(v)
case *connectionClosed:
p.reconnectToBroker()
case *flushRequest:
p.internalFlush(v)
case *closeProducer:
p.internalClose(v)
return
}
case <-p.batchFlushTicker.C:
p.internalFlushCurrentBatch()
}
}
}
```
when reconnect pulsar Broker
```
func (p *partitionProducer) reconnectToBroker() {
backoff := internal.Backoff{}
for {
if p.state != producerReady {
// Producer is already closing
return
}
d := backoff.Next()
p.log.Info("Reconnecting to broker in ", d)
time.Sleep(d)
err := p.grabCnx()
if err == nil {
// Successfully reconnected
p.log.WithField("cnx", p.cnx.ID()).Info("Reconnected producer to broker")
return
}
}
}
```
get connection frequently
```
func (c *rpcClient) getConn(logicalAddr *url.URL, physicalAddr *url.URL) (Connection, error) {
cnx, err := c.pool.GetConnection(logicalAddr, physicalAddr)
backoff := Backoff{1 * time.Second}
startTime := time.Now()
var retryTime time.Duration
if err != nil {
for time.Since(startTime) < c.requestTimeout {
retryTime = backoff.Next()
c.log.Debugf("Reconnecting to broker in {%v} with timeout in {%v}", retryTime, c.requestTimeout)
time.Sleep(retryTime)
cnx, err = c.pool.GetConnection(logicalAddr, physicalAddr)
if err == nil {
c.log.Debugf("retry connection success")
return cnx, nil
}
}
return nil, err
}
return cnx, nil
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] rueian edited a comment on issue #462: goroutine leak
Posted by GitBox <gi...@apache.org>.
rueian edited a comment on issue #462:
URL: https://github.com/apache/pulsar-client-go/issues/462#issuecomment-780357151
There are also goroutine leaks in `consumer_partition.go` and `connection.go`
https://github.com/apache/pulsar-client-go/blob/25f3075176f853f5f09d89b3b625e0646432735f/pulsar/internal/connection.go#L333-L338
The `incomingRequestsCh` never closed, therefore this `failLeftRequestsWhenClose` will never exit.
https://github.com/apache/pulsar-client-go/blob/25f3075176f853f5f09d89b3b625e0646432735f/pulsar/consumer_partition.go#L786
The `eventsCh` never closed, therefor this `runEventsLoop` will never exit.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] rueian commented on issue #462: goroutine leak
Posted by GitBox <gi...@apache.org>.
rueian commented on issue #462:
URL: https://github.com/apache/pulsar-client-go/issues/462#issuecomment-780357151
There are also goroutine leak on `consumer_partition.go` and `connection.go`
https://github.com/apache/pulsar-client-go/blob/25f3075176f853f5f09d89b3b625e0646432735f/pulsar/internal/connection.go#L333-L338
The `incomingRequestsCh` never closed, therefore this `failLeftRequestsWhenClose` will never exit.
https://github.com/apache/pulsar-client-go/blob/25f3075176f853f5f09d89b3b625e0646432735f/pulsar/consumer_partition.go#L786
The `eventsCh` never closed, there for this `runEventsLoop` will never exit.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] freeznet commented on issue #462: goroutine leak
Posted by GitBox <gi...@apache.org>.
freeznet commented on issue #462:
URL: https://github.com/apache/pulsar-client-go/issues/462#issuecomment-775620416
thanks @yuanweikang2020 for this issue, can you provide more context how to reproduce or verify this issue?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org