Same message is getting published to subscriber multiple times even after success acknowledgment

1,463 views
Skip to first unread message

Tinshuk Singh

unread,
May 5, 2020, 2:36:05 PM5/5/20
to Google Cloud Pub/Sub Discussions
Hi Team, 

I'm struggling with a behavior of pub/sub, which is, the same message is getting published to subscriber multiple times.
Please refer below table to understand the issue:


# Msg Id Received at Subscriber   Response Returned after processing Status
1 12345 2020-05-05 20:38:02.246 IST   2020-05-05 20:38:37.677 IST Failed
2 12345 2020-05-05 20:38:38.685 IST   2020-05-05 20:39:32.417 IST Success
3 12345 2020-05-05 20:38:39.359 IST   2020-05-05 20:39:52.151 IST Success

GCP Subscriber properties (PUSH):

Acknowledgement deadline : 300 Seconds
Message retention duration : 7 days

Subscriber : Java API (running on kubernetes with 3 instances )

#1, a message received from topic to subscriber which got failed due to some system failure
#2, as the message was failed subscriber tried to process the same message again which was successful
#3, the same message was received again to the subscriber and was processed successfully again.

As per my understanding, if the message was delivered at mentioned time at #2, it should not send the same message again at #3.
As per my use case, this subscriber is not expected to process the same message multiple times. Please let me know if this is something which can be handled.




Kamal Aboul-Hosn

unread,
May 5, 2020, 3:53:45 PM5/5/20
to Tinshuk Singh, Google Cloud Pub/Sub Discussions
Hi, Tinshuk,

Cloud Pub/Sub guarantees at-least-once delivery. That means that even if a message is processed by a subscriber and acknowledged, it is still possible that the message will be redelivered. It is a relatively rare occurrence (for a well-behaved subscriber, it tends to happen less than 0.5% of the time), but the subscriber still needs to be handle redelivery of messages. 

Kamal

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/90c5aa90-89fd-4751-be3d-3c9a69bbf3d2%40googlegroups.com.

Ondřej Fuchs

unread,
May 6, 2020, 2:55:00 PM5/6/20
to Google Cloud Pub/Sub Discussions
Hi Kamal,

I have the same problem in Google PubSub with duplicity of messages. But I got then more then 0,5%. Thanks for any advice.

I have one topic and one subscriber. I publish one message per ten minutes and I got one duplicity message every two hours. Duplicity messages hava the same message_ID. I also check nonACK messages in Google metrics and I didn't find any = Every message was ACK successfully. I also thought about ACK deadline, but process of one message < 2s and I set ack deadline to 20s. 

Here is piece of logs:

INFO:__main__:ID: 1181259733624335, Pubtime: 2020-05-05 16:24:58.357000+00:00, Received message: Message {} at time 2020-05-05 16:24:59.314107
INFO:__main__:MSG was ack at 2020-05-05 16:24:59.829352

INFO:__main__:ID: 1181259733624335, Pubtime: 2020-05-05 16:24:58.357000+00:00, Received message: Message {} at time 2020-05-05 16:25:10.725601
INFO:__main__:MSG was ack at 2020-05-05 16:25:11.195541


I know that google Cloud Pub/Sub guarantees at-least-once delivery, but this is too much I guess. 

Again thanks for any advice.

To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.

Kamal Aboul-Hosn

unread,
May 6, 2020, 3:08:00 PM5/6/20
to Ondřej Fuchs, Google Cloud Pub/Sub Discussions
Hi, Ondřej,

Take a look at an answer I posted on Stack Overflow: https://stackoverflow.com/a/58001511/1121288. It talks about some causes of duplicates. You may need to reach out to support with your subscription information for further assistance.

Kamal

To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/329cae9b-edf4-4f48-a154-2ea07744ff6b%40googlegroups.com.

Tinshuk Singh

unread,
May 7, 2020, 3:22:44 PM5/7/20
to Google Cloud Pub/Sub Discussions
Thanks Kamal for the reply. Just to confirm, is this behavior applicable for "Pull" subscriber as well?

Tinshuk.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.

Kamal Aboul-Hosn

unread,
May 7, 2020, 5:07:29 PM5/7/20
to Tinshuk Singh, Google Cloud Pub/Sub Discussions
Yes, it is generally applicable for pull subscribers as well. The point about large backlogs and streaming pull subscribers doesn't apply if you are using the synchronous Pull API.

Kamal

To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/2d1ad7ef-8d9b-4909-bf4e-e6168d19640b%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages