Skip to content

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

@idehong

Description

@idehong

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

Metadata

Metadata

Assignees

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