Repository navigation
Pub/Sub streamingPull subscriber: large number of duplicate messages, modifyAckDeadline calls observed #2465
Description
Activity
- addedapi: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
on Sep 26, 2017 @kir-titievsky Do you have a workload that can reliably reproduce this? If you do, could you try removing the flow control (hopefully the workload isn't so large that it crashes your machine)? If the problem goes away, this is probably a dup of #2452; the symptoms are nearly identical.
If this doesn't fix the problem, could you share the repro workload with me?
EDIT: If the workload is too large to remove flow control, the fix for the linked issue is already in master, so we can to test with that version. Slightly less convenient as we'll need to compile from source.
The behaviour observed with #2452 was seen with the older non streaming pull implementation (0.21.1-beta). This issue came about when using the newer client library. It might also be worth noting that with the Flow Control set to 1000 max messages on the older library duplicates where not seen, just the stuck messages.
@robertsaxby That makes sense. I can reproduce the messages getting stuck, but not redelivery.
@kir-titievsky I need a little help understanding the spreadsheet. Are all rows for the same message? I assume that
stream_iduniquely identifies a StreamingPull stream? Ie, one physical computer can have multiple IDs by opening many streams, but one stream ID is unique to one computer?FWIW, I have a PR opened to address a potential race condition in streaming. It's concievable that the race condition causes this problem.
If you could set up a reproduction, please let me know.
@pongad You are right on all counts about the spreadsheet. All rows are for the same message, including traffic from several bidi streams, that had been opened at different times.
@pongad Did a couple experiments:
- No flow control, single machine: everything is acked within seconds ~10 modify ack deadline operations for 10K messages.
- Added a synchronous 50ms sleep to every operation. Got a peak of 7K modifyAckDeadline operations over a minute, about 10K total. modifyAckDeadline ops peaked around the same time as Ack operations. Overall, ~2-3 minutes of activity. This is very much unexpected as the subscription has a 10 minute ack deadline (at least that's the setting).
To summarize: This is an issue on the server side. Currently the client library does not have enough information to properly handle ack deadlines.
In the immediate term, consider using
v0.21.1. That version uses a different (slower) pubsub endpoint, that isn't affected by this problem.Pubsub team is working on a server-side mitigation for this. The client lib will need to be updated to take advantage of it. Fortunately, this new feature "piggybacks" on an already existing one, so the work on client lib can progress right away.
I hope to create a PR for this soon.
Update: the server side release should happen this week. The feature should be enabled next week. The client (in master) has already been modified to take advantage of this new feature.
When the server feature is enabled, we'll test to see how this helps.
The server-side fix has landed. If you are affected, could you try again and see if you observe fewer duplicates?
While we expect the fix to help reduce duplication on older client libs, I'd encourage moving to latest release (v0.30.0) since more fixes has landed during that time.
We are seeing this behavior currently. We are using
v0.30.0-betaof the pubsub library, and our subscriptions are all set to a 60s ack deadline. We have a subscription that is currently extended the deadline for over 750K unacked messages:Screenshot of stackdriver below:
https://screencast.com/t/KogMzx0q7f5Our receiver always performs either
ack()ornack(), and the occasional message that sneaks through when symptoms look like this complete within 1s, usually faster.I deleted the subscription and recreated it, and saw the modack calls drop to zero, only to climb back almost instantly to where they were before.
Is there anything else that will help you/us troubleshoot this issue?
- Eric, how does the mod ack rate compare to your Publish and ack rates?On Mon, Dec 11, 2017 at 9:19 AM Eric Martineau ***@***.***> wrote: We are seeing this behavior currently. We are using v0.30.0-beta of the pubsub library, and our subscriptions are all set to a 60s ack deadline. We have a subscription that is currently extended the deadline for over 750K unacked messages: Screenshot of stackdriver below: https://screencast.com/t/KogMzx0q7f5 Our receiver always performs either ack() or nack(), and the occasional message that sneaks through when symptoms look like this complete within 1s, usually faster. I deleted the subscription and recreated it, and saw the modack calls drop to zero, only to climb back almost instantly to where they were before. Is there anything else that will help you/us troubleshoot this issue? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#2465 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ARrMFhZdtKQEgS0G7y0c3GvvhizKQlzHks5s_WQXgaJpZM4Pk8_U> .-- Kir Titievsky | Product Manager | Google Cloud Pub/Sub
24 remaining items
That sounds like a bug somewhere. The re-delivery after an hour, in particular, makes me suspicious. If you could, might you file a separate bug with a reproduction? If not,
- Might you open a support case with GCP support, if you have a support plan, detailing when you observed this on what project and subscription?
- If not, could you send the same to cloud-pubsub@google.com? No guarantees, but I might be able to take a look.
An alternative explanation for this behavior is that the acks never succeed. Which might make this a client-side bug. But hard to tell.
We have experienced similar kind of issue here with the java google-cloud-pubsub lib GA version 1.31.0. We don't get the duplicate messages but the messages seem stuck in the queue even though we send ack back. After restarts the clients, the stuck messages got cleared up.
@luann-trend What does "stuck" here mean? Are new messages not being processed?
@pongad The new messages still being processed, only there couple hundreds message keep get redelivered but not able to process for some reason. We have experienced the same issues on 2 different cluster environments after about 4-5 days start using the new Java Google-pubsub client GA version.
@luann-trend This is interesting. Is it possible that the messages are causing you to throw exception? We catch exception and nack messages automatically, assuming that user code failed to process it. Do you know the duration of time between redelivers?
Should have been fixed in #3743
- added 2 commits that reference this issue
on Feb 20, 2026 - added a commit that references this issue
on Mar 30, 2026 - added a commit that references this issue
on Jul 13, 2026
Large number of duplicate messages is observed with Pub/Sub streamingPull client library using code that pulls from a Pub/Sub subscription and inserts messages into BigQuery with a synchronous blocking operation, with flowControl set to max 500 outstanding messages. See [1] for code.
For the same code, we also observe an excessive number of modifyAckDeadline operations (>> streamingPull message operations). And tracing a single message, we see modifyAcks and Acks in alternating order for the same message (modAck, modAck, Ack, modAck, Ack) [2]. This suggest that the implementation might fail to remove Ack'ed messages from a queue of messages to process and keep re-processing messages already on the client. This also suggests that ack requests may not actually be sent.
[2] https://docs.google.com/spreadsheets/d/1mqtxxm0guZcOcRy8ORG0ri787XLQZNF_FLBujAiayFI/edit?ts=59cac0f0#gid=2139642597
[1]