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

flowControl.maxMessages is being ignored #784

Closed
sjb933 opened this issue Oct 17, 2019 · 6 comments
Closed

flowControl.maxMessages is being ignored #784

sjb933 opened this issue Oct 17, 2019 · 6 comments
Assignees
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. type: question Request for information or clarification. Not an issue.

Comments

@sjb933
Copy link

sjb933 commented Oct 17, 2019

flowControl.maxMessages is seemingly being ignored. I've created a small focused test repo to highlight the issue.

Environment details

  • OS: Mac OSX
  • Node.js version: 8.16.2
  • npm version: 6.4.1
  • @google-cloud/pubsub version: 1.1.2

Steps to reproduce

See: https://github.com/sjb933/gcloud-pubsub-maxMessage-bug

  1. Clone project
  2. npm install
  3. Open test.ts and populate GOOGLE_PROJECT_ID with a proper project ID which you have authenticated access to
  4. Execute the test with npm start
  5. Observe the output

Observations:

Expected: 10 messages published, only 2 process concurrently.

Actual: 10 messages published, all 10 process concurrently.

@sjb933
Copy link
Author

sjb933 commented Oct 17, 2019

The output produced from my test script:

> [email protected] start /Users/shane/Code/pubsub-bug
> ts-node test.ts

Concurrency within tolerances
Concurrency within tolerances
ERROR: Concurrently processing 10 messages (flowControl.maxMessages = 2)
ERROR: Concurrently processing 10 messages (flowControl.maxMessages = 2)
Concurrency within tolerances
Deleting test topic: test-topic-029095cb

The messages in my script are ACK'd on a timeout and there should only ever be 2 running concurrently.

@callmehiphop
Copy link
Contributor

@sjb933 the backend doesn't actually let us configure how many messages it sends per batch, so unless the allowExcessMessages flag is set to false you'll get more. Can you try out the following config?

subscription.setOptions({
  flowControl: {
    allowExcessMessages: false,
    maxMessages: 2
  }
});

@callmehiphop callmehiphop added the type: question Request for information or clarification. Not an issue. label Oct 17, 2019
@sjb933
Copy link
Author

sjb933 commented Oct 17, 2019

@callmehiphop confirmed, allowExcessMessages: false resolves the issue. I'm in the process of updating to newer libs and this was revealed in our consuming code's tests.

Was this a new option, or did it perhaps default to false before?

Thanks you for the quick support!

@callmehiphop
Copy link
Contributor

I think it shipped with v0.23.0 which was released back in January. Before that we had behavior that mirrored setting it to false.

@google-cloud-label-sync google-cloud-label-sync bot added the api: pubsub Issues related to the googleapis/nodejs-pubsub API. label Jan 31, 2020
@mnahkies
Copy link

mnahkies commented Aug 6, 2020

@sjb933 the backend doesn't actually let us configure how many messages it sends per batch, so unless the allowExcessMessages flag is set to false you'll get more. Can you try out the following config?

@callmehiphop seems like this has recently changed (#1041) - does this mean we no longer require the allowExcessMessages: false option?

@lucasjohnston
Copy link
Contributor

Can confirm that you still need allowExcessMessages: false to use maxMessages.
The example for Lease Management in the docs should probably reflect this :)

https://cloud.google.com/pubsub/docs/pull#synchronous_pull_with_lease_management

lucasjohnston added a commit to lucasjohnston/nodejs-pubsub that referenced this issue Mar 30, 2021
feywind added a commit that referenced this issue Apr 14, 2021
feywind pushed a commit to feywind/nodejs-pubsub that referenced this issue Nov 12, 2024
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/5f7f9c6d-c75a-4c60-8bb8-0026a14cead7/targets

- [ ] To automatically regenerate this PR, check this box.

PiperOrigin-RevId: 325949033
Source-Link: googleapis/googleapis@94006b3
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. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants