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

Pub/Sub: Send modify_ack_deadline requests in chunks #9103

Closed
mwytock opened this issue Aug 26, 2019 · 6 comments · Fixed by #9594
Closed

Pub/Sub: Send modify_ack_deadline requests in chunks #9103

mwytock opened this issue Aug 26, 2019 · 6 comments · Fixed by #9594
Assignees
Labels
api: pubsub Issues related to the Pub/Sub API. 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.

Comments

@mwytock
Copy link

mwytock commented Aug 26, 2019

Currently leaser is limited in total number of messages (<2000?) which is a problem for use cases with many small messages.

Same issue was solved in nodejs library here: googleapis/nodejs-pubsub#65

@mwytock
Copy link
Author

mwytock commented Aug 26, 2019

More context: lease tries to ack all messages at the same time which results in the following error

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py", line 335, in send
    self._send_unary_request(request)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py", line 322, in _send_unary_request
    ack_deadline_seconds=deadline,
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/pubsub_v1/_gapic.py", line 40, in <lambda>
    fx = lambda self, *a, **kw: wrapped_fx(self.api, *a, **kw)  # noqa
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/pubsub_v1/gapic/subscriber_client.py", line 821, in modify_ack_deadline
    request, retry=retry, timeout=timeout, metadata=metadata
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/gapic_v1/method.py", line 143, in __call__
    return wrapped_func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/retry.py", line 273, in retry_wrapped_func
    on_error=on_error,
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/retry.py", line 182, in retry_target
    return target()
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/timeout.py", line 214, in func_with_timeout
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/grpc_helpers.py", line 59, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "/usr/local/lib/python2.7/dist-packages/six.py", line 737, in raise_from
    raise value
InvalidArgument: 400 Request payload size exceeds the limit: 524288 bytes.

@busunkim96 busunkim96 added the api: pubsub Issues related to the Pub/Sub API. label Aug 26, 2019
@busunkim96 busunkim96 changed the title Send modify_ack_deadline requests in chunks Pub/Sub: Send modify_ack_deadline requests in chunks Aug 26, 2019
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Aug 27, 2019
@plamut
Copy link
Contributor

plamut commented Aug 27, 2019

@mwytock Thanks for the report!

By default the streaming pull is configured to lease a maximum of 100 messages, or 100 MiB of messages, whichever limit is hit first.
https://github.com/googleapis/google-cloud-python/blob/master/pubsub/google/cloud/pubsub_v1/types.py#L71-L73

Any messages received on top of that are put in a waiting buffer, and the message stream gets paused. Sending 100 or less ACK IDs should work fine, thus I'm wondering if you maybe use custom FlowControl settings? Or send ACK and mofiyAckDeadline requests manually?

Also, are there any other interesting entries in the log referring to pausing/resuming the message stream? Things like the following:

  • "Message backlog over load at X.YZ, pausing."
  • "Current load is X.YZ, resuming consumer."
  • "Did not resume, current load is X.YZ."

Any such info would be useful, thanks!

@mwytock
Copy link
Author

mwytock commented Aug 27, 2019 via email

@plamut
Copy link
Contributor

plamut commented Aug 27, 2019

@mwytock Thanks for the quick response.

It seems that the defaults are fine then, but I agree that if a user can customize this to a high number, the resulting error message should be more descriptive, or the error should not occur at all.

Since the max request size limit is imposed by the backend, a quick way around it would indeed be raising an error if the FlowControl.max_messages is set to to high a number.

Alternatively, sending the message(s) in smaller batches could be implemented, similarly to what the Node.js client did.

@plamut plamut 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. and removed triage me I really want to be triaged. labels Aug 27, 2019
@mwytock
Copy link
Author

mwytock commented Aug 27, 2019 via email

@plamut
Copy link
Contributor

plamut commented Aug 27, 2019

I will definitely put this up for consideration to the product team. There is a threshold beyond which the max_messages setting is not really sensible anymore for practical purposes, although on the other hand, consistency in client implementations across different languages is also high on the list.

It's good that we now have this issue documented, thus thanks again for reporting it!

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 Pub/Sub API. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants