Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When topic is deleted forced, don't to tigger reconnect logic #623

Closed
wolfstudy opened this issue Sep 28, 2021 · 1 comment · Fixed by #627
Closed

When topic is deleted forced, don't to tigger reconnect logic #623

wolfstudy opened this issue Sep 28, 2021 · 1 comment · Fixed by #627

Comments

@wolfstudy
Copy link
Member

Expected behavior

When topic is deleted forced, under normal circumstances, we should force the producer to be deleted. What the client feels is that the producer has been closed, instead of triggering the logic of reconnection.

Actual behavior

When topic is deleted forced, the request triggers the logic of reconnection.

Steps to reproduce

  1. Start standalone (e.g: 2.8.0) and set allowAutoTopicCreation=false in standalone.conf
  2. Run the demo of producer:
func main() {
	client, err := pulsar.NewClient(pulsar.ClientOptions{
		URL: "pulsar://localhost:6650",
	})

	if err != nil {
		log.Fatal(err)
	}

	defer client.Close()

	producer, err := client.CreateProducer(pulsar.ProducerOptions{
		Topic: "topic-1",
	})
	if err != nil {
		log.Fatal(err)
	}

	defer producer.Close()

	ctx := context.Background()

	for i := 0; i < 1000000; i++ {
		if msgId, err := producer.Send(ctx, &pulsar.ProducerMessage{
			Payload: []byte(fmt.Sprintf("hello-%d", i)),
		}); err != nil {
			log.Fatal(err)
		} else {
			time.Sleep(1 * time.Second)
			log.Println("Published message: ", msgId)
		}
	}
}
  1. Run the cmd to force delete topic-1
 bin/pulsar-admin topics delete topic-1 -f
  1. Observing the behavior of this producer, we will find that we have triggered the reconnection logic.

image

The same code logic, we can see the following error message in java, this is the behavior we expect:

image

System configuration

Pulsar version: x.y

@wolfstudy
Copy link
Member Author

And the java demo as follows:

public static void main(String[] args) throws PulsarClientException {
        PulsarClient client = PulsarClient.builder()
                .serviceUrl("pulsar://localhost:6650")
                .build();

        final String topic = "test-topic-002";
        final int msgCount = 100000;

        Producer<byte[]> producer = client.newProducer()
                .topic(topic)
                .create();
        for (int i = 0; i < msgCount; i++) {
            String value = "new msg No." + i;
            MessageId msgId = producer.newMessage()
                    .value(value.getBytes())
                    .send();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException exception) {
                exception.printStackTrace();
            }
            System.out.println("===>>> produce msg id:" + new String(msgId.toString()) + ", value:" + value);
        }
        producer.flush();
}

zymap pushed a commit that referenced this issue Sep 29, 2021
Signed-off-by: xiaolongran <xiaolongran@tencent.com>


Fixes #623


### Motivation

As #623 said, when the topic is deleted forced, we don't should trying to reconnect, instead of giving up reconnection.


### Modifications

- Fix prodcuer reconnetion logic
- Fix consumer reconnection logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant