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

Issues with explicitely ack() messages remaining in queue #1856

Closed
PILLOWPET opened this issue Nov 24, 2023 · 5 comments
Closed

Issues with explicitely ack() messages remaining in queue #1856

PILLOWPET opened this issue Nov 24, 2023 · 5 comments
Assignees
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@PILLOWPET
Copy link

Environment details

  • OS: Mac OS Sonoma
  • Node.js version: 18.18.1
  • npm version: 9.8.1
  • @google-cloud/pubsub version: 4.0.7

Steps to reproduce

  1. I'm using the library locally to develop and I have a development environnement on PubSub.
  2. I have a Post endpoint n my app that emits one event myEvent to a given topic foo on PubSub.
  3. For this topic I have a bar subscription that is supposed to change a field in my database
  4. When the DB operation is done, I call message.ack() and then the function finishes.
  5. I kill the app locally and relaunch it, re-subscribing to the topic
  6. I receive the same message even though it was already acked in the previous session
  7. Messages are never acked and keep piling up in the Pubsub dashboard

There is likely something that I'm missing, I don't have exactly once delivery enabled but I don't understand why a message that I explicitely ack remains in the queue and is sent again when I add my subscription again to the topic by relaunching the app.
My PubSub options:

import { PubSub } from "@google-cloud/pubsub";

export const getDefaultSubscriptionOptions = (): Parameters<PubSub["createSubscription"]>[2] => ({
    ackDeadlineSeconds: 60,
    retryPolicy: {
        maximumBackoff: {
            seconds: 180,
        },
        minimumBackoff: {
            seconds: 60,
        },
    },
    flowControl: {
        maxMessages: 1,
    },
    deadLetterPolicy: {
        deadLetterTopic: `projects/dev/topics/deadletter`,
        maxDeliveryAttempts: 5,
    },
});

Thanks!

@PILLOWPET PILLOWPET added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Nov 24, 2023
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/nodejs-pubsub API. label Nov 24, 2023
@feywind
Copy link
Collaborator

feywind commented Nov 29, 2023

@PILLOWPET Did you try await sub.close() on your Subscription object before shutting down? It's likely the ack is queued but not sent in time.

@feywind feywind added type: question Request for information or clarification. Not an issue. and removed type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Nov 29, 2023
@Onzeka
Copy link

Onzeka commented Dec 15, 2023

Hello @feywind,

I work with @PILLOWPET on the same project and I managed to narrow down the issue. Even without shutting down the app we can see that the message is not removed from the subscription. Actually in our tests we only shut down the app to make sure that all the messages in the queue are pulled again after restarting it.

I noticed that this issue (being able to receive messages but not to acknowledge them) occurs depending on the number of active subscriptions we have in our app, if we have a number of 20 or above active subscriptions in our app the acknowledgment does not work as expected, if we have a number 19 or under active subscriptions it works fine. It may be also worth to mention that we, currently for this app, have for each distinct subscription - one distinct associated topic.

@Onzeka
Copy link

Onzeka commented Dec 16, 2023

Looks like this: #1705 and this behaviour is also mentioned here https://cloud.google.com/nodejs/docs/reference/pubsub/latest/pubsub/subscription-class

We will try to implement a fix using the links mentioned above to see if it fixes our issue but if that is the case I believe that the library should raise a warning or an error when the maximum number of stream is reached or exeeded.

@feywind feywind self-assigned this Dec 18, 2023
@feywind feywind added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed type: question Request for information or clarification. Not an issue. labels Dec 18, 2023
@feywind
Copy link
Collaborator

feywind commented Dec 18, 2023

I agree that that's annoying. I'll have to check with the other language authors, because we're trying to keep them more in sync going forward, but it seems like a reasonable request.

@feywind
Copy link
Collaborator

feywind commented May 2, 2024

Closed in favour of #1917

@feywind feywind closed this as completed May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants