hrsakai opened a new issue #5324: [go client] Producer::Close() may get stuck
URL: https://github.com/apache/pulsar/issues/5324
 
 
   **Describe the bug**
   In the situation I confirmed, when entering [the 
logic](https://github.com/apache/pulsar/blob/v2.3.2/pulsar-client-cpp/lib/ProducerImpl.cc#L478-L484),
 
[`C._pulsar_producer_close_async()`](https://github.com/apache/pulsar/blob/v2.3.2/pulsar-client-go/pulsar/c_producer.go#L228)
 gets stuck with [`c<-err` in 
callback](https://github.com/apache/pulsar/blob/v2.3.2/pulsar-client-go/pulsar/c_producer.go#L223)
 and 
[`<-c`](https://github.com/apache/pulsar/blob/v2.3.2/pulsar-client-go/pulsar/c_producer.go#L224)
 is not executed.
   Therefore, `Producer::Close()` does not finish.
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. Producer connects to broker
   2. Revoke the producer's permission to produce(e.g. `pulsar-admin namespaces 
revoke-permission  --role "producer.role" public/global/n1`)
   3. Execute `Producer.Close()`
   
   
   I confirmed I can avoid the issue in the following ways.
   But I don’t know the best way(Should we modify c++ code?).
   1. Use `go`
   ```
   func (p *producer) CloseAsync(callback func(error)) {
   -    C._pulsar_producer_close_async(p.ptr, savePointer(callback))
   +    go C._pulsar_producer_close_async(p.ptr, savePointer(callback))
   }
   ```
   
   2. Use `C.pulsar_producer_close()` like `Client.Close()`
   ```
   func (p *producer) Close() error {
         res := C.pulsar_producer_close(p.ptr)
         if res != C.pulsar_result_Ok {
                 return newError(res, "Failed to close Pulsar client")
         } else {
                 return 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:
[email protected]


With regards,
Apache Git Services

Reply via email to