apache / apache/pulsar-client-go

[Bug] The producer is sometimes blocked when calling producer.SendAsync

Open
#1,365 0 comments 0 reactions 1 assignee Claimed by @idehong View on GitHub
Dominant language
Go
Stars
745
Forks
389
Avg merge
3d 20h
Merged PRs (30d)
3

Description

#### Expected behavior
When calling producer.SendAsync to produce messages, it cannot be blocked and deadlock

#### Actual behavior

When calling producer.SendAsync to produce a message, an error occurs. The producer.Close interface is called in the callback of SendAsync, causing the process to deadlock.

same goroutinue are deadlock,call stack:

```
sync.runtime_SemacquireMutex(0x1288980?, 0x20?, 0x15b15a0?)
/myapp/go1.23.0/go/src/runtime/sema.go:95 +0x25
sync.(*Mutex).lockSlow(0xc00084b0ac)
/myapp/go1.23.0/go/src/sync/mutex.go:173 +0x15d
sync.(*Mutex).Lock(0x11c4b80?)
/myapp/go1.23.0/go/src/sync/mutex.go:92 +0x32
sync.(*Once).doSlow(0xc00084b0a8, 0xc001ae7098)
/myapp/go1.23.0/go/src/sync/once.go:72 +0x3a
sync.(*Once).Do(0xc00084b0a8, 0xc001ae7098)
/myapp/go1.23.0/go/src/sync/once.go:67 +0x33
github.com/apache/pulsar-client-go/pulsar.(*producer).Close(0xc9870a?)
```

#### Steps to reproduce

1. call producer.SendAsync
2. call producer.Close in the producer.SendAsync failure callback function

e.g

```
producter.SendAsync(ctx, p.constructMsg(msg), func(id pulsar.MessageID, pm *pulsar.ProducerMessage, err error) {
// check error, like "connection error" , "connection closed" etc...
if err != nil && needClose(err) {
p.CloseProduct()
}
// do something

})
```

#### System configuration
**Pulsar version**: 0.14

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.