question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Once a topic is terminated it can no longer be read from by a new Consumer

See original GitHub issue

Describe the bug Topic termination documentation says

Terminate a topic (disallow further messages from being published on the topic)

But once you terminate a topic, even if the retention settings allow data retention, a new consumer cannot read from it.

To Reproduce Steps to reproduce the behavior:

  1. Produce data to a topic
./pulsar-client --url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-protocol SNI produce persistent://cogito-dialog/wav/frankTest7 -f ~/platform2-signal/signal-stream-client-library/src/intTest/resources/python.wav
  1. Terminate The topic
./apache-pulsar-2.6.1/bin/pulsar-admin --admin-url http://platform-pulsar-broker:8080 topics terminate  persistent://cogito-dialog/wav/frankTest7
  1. Consume from the Topic with SubcriptionInitialPosition = EARLIEST
./pulsar-client --url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-protocol SNI consume -s tcpingress-test2 -p Earliest persistent://cogito-dialog/wav/frankTest7 -t Shared
  1. Get a message indicating we reached the end of the topic
09:12:07.353 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://cogito-dialog/wav/frankTest7][tcpingress-test2] Subscribed to topic on pulsar.saas-dev.cogitocorp.us/100.26.7.97:7443 -- consumer: 0
09:12:07.398 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ClientCnx - [pulsar.saas-dev.cogitocorp.us/100.26.7.97:7443] Broker notification reached the end of topic: 0
09:12:07.399 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [tcpingress-test2] [persistent://cogito-dialog/wav/frankTest7] [8778c] Consumer has reached the end of topic

Retention period is 3 days

 ./apache-pulsar-2.6.1/bin/pulsar-admin --admin-url http://platform-pulsar-broker:8080 namespaces get-retention cogito-dialog/wav
{
  "retentionTimeInMinutes" : 4320,
  "retentionSizeInMB" : -1
}

Expected behavior The Admin Docs say Terminate a topic (disallow further messages from being published on the topic) https://pulsar.apache.org/docs/en/pulsar-admin/#terminate Also the Javadoc says Terminate a topic. A topic that is terminated will not accept any more messages to be published and will let consumer to drain existing messages in backlog https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java#L2168-L2169 Neither says anything about future consumers

So either

  1. Topic termination should still allow new consumers to read data from the topic
  2. (If this works as designed) the Documentation should be updated to clearly indicate that i) Existing consumers once they catch up to the end will be notified there is no more data ii) New consumers will get NO data

Additional context

  • Using Apache Pulsar 2.6.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
frankjkellycommented, Jan 19, 2021

I retried with the command line tools for Pulsar 2.6.1 ensuring that the subscriber name was new each time and was able to reproduce the behavior

17:13:18.081 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ClientCnx - [pulsar.saas-dev.cogitocorp.us/54.82.124.115:7443] Broker notification reached the end of topic: 0
17:13:18.081 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [subcriber5] [persistent://cogito-dialog/wav/test5] [48326] Consumer has reached the end of topic

TEST CASE 1: No Terminate Producer

$ ./pulsar-client --url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-protocol SNI produce persistent://cogito-dialog/wav/testNoTerminate -f ~/platform2-signal/signal-stream-client-library/src/intTest/resources/python.wav

Consumer

$ ./pulsar-client --url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-protocol SNI consume -p Earliest -s subcriberNoTerminate persistent://cogito-dialog/wav/testNoTerminate -t Shared    

Response

17:15:31.672 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://cogito-dialog/wav/testNoTerminate][subcriberNoTerminate] Subscribing to topic on cnx [id: 0x4a36f046, L:/10.250.8.90:62168 - R:pulsar.saas-dev.cogitocorp.us/3.217.29.231:7443]
17:15:31.725 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://cogito-dialog/wav/testNoTerminate][subcriberNoTerminate] Subscribed to topic on pulsar.saas-dev.cogitocorp.us/3.217.29.231:7443 -- consumer: 0

TEST CASE 2: Include Terminate Producer

$ ./pulsar-client --url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-protocol SNI produce persistent://cogito-dialog/wav/testWithTerminate -f ~/platform2-signal/signal-stream-client-library/src/intTest/resources/python.wav

Termination

$ ./apache-pulsar-2.6.1/bin/pulsar-admin --admin-url http://platform-pulsar-broker:8080 topics terminate  persistent://cogito-dialog/wav/testWithTerminate
Warning: Nashorn engine is planned to be removed from a future JDK release
Topic succesfully terminated at 951286:0:-1

Consumer

$ ./pulsar-client --url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-url pulsar+ssl://pulsar.saas-dev.cogitocorp.us:7443 --proxy-protocol SNI consume -p Earliest -s subcriberWithTerminate persistent://cogito-dialog/wav/testWithTerminate -t Shared

Response

17:17:42.151 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://cogito-dialog/wav/testWithTerminate][subcriberWithTerminate] Subscribing to topic on cnx [id: 0x2e169889, L:/10.250.8.90:62185 - R:pulsar.saas-dev.cogitocorp.us/54.82.124.115:7443]
17:17:42.293 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [persistent://cogito-dialog/wav/testWithTerminate][subcriberWithTerminate] Subscribed to topic on pulsar.saas-dev.cogitocorp.us/54.82.124.115:7443 -- consumer: 0
17:17:42.477 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ClientCnx - [pulsar.saas-dev.cogitocorp.us/54.82.124.115:7443] Broker notification reached the end of topic: 0
17:17:42.478 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [subcriberWithTerminate] [persistent://cogito-dialog/wav/testWithTerminate] [be3a5] Consumer has reached the end of topic

NOTE: If I do the reset-cursor

$ ./apache-pulsar-2.6.1/bin/pulsar-admin --admin-url http://platform-pulsar-broker:8080 topics reset-cursor  persistent://cogito-dialog/wav/testWithTerminate -s subcriberWithTerminate -t 2d

I do get data back But again it appears surprising that a new subscription, created after topic termination, needs to have its cursor reset

0reactions
tisonkuncommented, Dec 9, 2022

Closed as stale. Please create a new issue if it’s still relevant to the maintained versions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Terminate Kafka Console Consumer when all the messages ...
I need to stop the kafka consumer once I have read all the messages from the queue. Can somebody provide any info on...
Read more >
Amazon SQS visibility timeout - Amazon Simple Queue Service
When a consumer receives and processes a message from a queue, the message remains in the queue. Amazon SQS doesn't automatically delete the...
Read more >
Service Bus messaging exceptions - Azure - Microsoft Learn
To resolve the issue, read and complete the messages from the dead-letter queue, as you would from any other queue. You can use...
Read more >
2022 Code of Ethics & Standards of Practice
In the interpretation of this obligation, REALTORS® can take no safer guide ... or non-agency relationship recognized by law continues after termination of ......
Read more >
Customer Rights Responsibilities - CT.gov
If you are a residential customer, your service cannot be shut off on a Friday ... law mandates that no electric or gas...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found