Skip to content

[go client] Producer::Close() may get stuck #5324

@hrsakai

Description

@hrsakai

Describe the bug
In the situation I confirmed, when entering the logic, C._pulsar_producer_close_async() gets stuck with c<-err in callback and <-c 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))
}
  1. 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
      }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugThe PR fixed a bug or issue reported a bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions