GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add gateway timeout to pubsub pull by daspecster · Pull Request #2576 · googleapis/google-cloud-python

Conversation

@daspecster

@daspecster daspecster commented Oct 20, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Based from #2575.

Implement exception for pubsub subscription pull.

Fixes: #2574

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daspecster daspecster added the api: pubsub Issues related to the Pub/Sub API. label Oct 20, 2016
@daspecster daspecster assigned tseaver and dhermes Oct 20, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 20, 2016
@dhermes

dhermes commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

Ref: https://github.com/googleapis/googleapis/blob/37cc0e5acae50ee91f00827a7010c3b07dfa5311/google/rpc/code.proto#L69-L70

daspecster reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

Relates to my comment on #2496

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dhermes
dhermes approved these changes Oct 20, 2016
View reviewed changes

@dhermes dhermes left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending Travis

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tseaver

tseaver commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

Rather than raising a 504, wouldn't we rather match the semantics of the JSON API and return an empty list?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster

daspecster commented Oct 20, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@tseaver could do that. How would the user know to retry in that case?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

@tseaver I am 👎 on swallowing exceptions. It's up to the API implementers to make sure the JSON and gRPC surface is sufficiently similar.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

@daspecster

How would the user know to retry in that case?

A timeout exception due to no messages isn't really "exceptional." Long-running subscriber processes are going to be retrying anyway, inside a while True sort of loop. Short-lived subscribers just iterate over the (possibly empty) list of messages and exit.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster

daspecster commented Oct 20, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@tseaver, wouldn't the while True: continue after the DEADLINE_EXCEEDED in that case?

Or I guess I would think that if the deadline was exceeded then the user would need to take action on that information?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

@dhermes

It's up to the API implementers to make sure the JSON and gRPC surface is sufficiently similar.

We paper over lots of differences between the different API surfaces already: it has been an explicit goal that the user doesn't notice or care about them.

@daspecster I'm arguing that users shouldn't need to care about this gRPC-only timeout exception at all: if we propagate it, then they have to catch it, but it doesn't "mean" anything to them beyond "there are no messages to process," which is exactly what returning an empty sequence tells them.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster

daspecster commented Oct 20, 2016

Copy link
Copy Markdown
Contributor Author

A timeout exception due to no messages isn't really "exceptional."

@tseaver I'm not seeing where this is the same or different from the ackDeadline or other normal operations.

It sounds like if there were no messages after the deadline then it would just return nothing and not throw an error?

Received Pub/Sub messages. The Pub/Sub system will return zero messages if there are no more available in the backlog. The Pub/Sub system may return fewer than the maxMessages requested even if there are more messages available in the backlog.

https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pullresponse

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

We paper over lots of differences between the different API surfaces already

@tseaver I'm not disputing that but this is an error being converted into a successful (empty) response. We don't even have a repro yet confirming this is intended / deterministic behavior. We should at least hear from someone on the API team / see official docs that confirm a gRPC 504 is equivalent to an empty result.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

I'm not seeing where this is the same or different from the ackDeadline or other normal operations.

ackDeadline is a configuration option for the Subscription: pull-mode subscribers are required to ack pulled messages within that interval, or else they get queued for redelivery. It can't be relevant to #2574, as the DEADLINE_EXCEEED message is being raised inside subscription.pull().

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver tseaver added the backend label Oct 20, 2016
@tseaver

tseaver commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

We should at least hear from someone on the API team / see official docs that confirm a gRPC 504 is equivalent to an empty result.

@tmatsuo Can you chime in here?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster

daspecster commented Oct 24, 2016

Copy link
Copy Markdown
Contributor Author

@tmatsuo could you check this out when you have a second?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster
daspecster force-pushed the add-gateway-timeout-to-pubsub-pull branch from bd83972 to 2a078e0 Compare October 30, 2016 20:11
@daspecster

daspecster commented Nov 3, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@dhermes @tseaver, what shall I do with this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster
daspecster force-pushed the add-gateway-timeout-to-pubsub-pull branch from 2a078e0 to ddc98d4 Compare November 14, 2016 21:05
@daspecster

daspecster commented Nov 16, 2016

Copy link
Copy Markdown
Contributor Author

Bump

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Nov 18, 2016

Copy link
Copy Markdown
Contributor

@daspecster Can you give snippets / stacktraces of what happens for the exact same client code, but one with gRPC disabled and one with it enabled?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster

daspecster commented Nov 21, 2016

Copy link
Copy Markdown
Contributor Author

@dhermes @tseaver.

Here is my test file.

from google.cloud import pubsub


client = pubsub.Client()

topic = client.topic('test-padding')
if not topic.exists():
    topic.create()

subscription = topic.subscription('test-padding')

if not subscription.exists():
    subscription.create()

messages = subscription.pull()
print(messages)

With gRPC:

$ python test_pubsub_padding.py
Traceback (most recent call last):
  File "test_pubsub_padding.py", line 18, in <module>
    messages = subscription.pull()
  File "/Users/daspecster/.virtualenvs/gct/lib/python2.7/site-packages/google/cloud/pubsub/subscription.py", line 328, in pull
    self.full_name, return_immediately, max_messages)
  File "/Users/daspecster/.virtualenvs/gct/lib/python2.7/site-packages/google/cloud/pubsub/_gax.py", line 414, in subscription_pull
    return_immediately=return_immediately)
  File "/Users/daspecster/.virtualenvs/gct/lib/python2.7/site-packages/google/cloud/gapic/pubsub/v1/subscriber_api.py", line 545, in pull
    return self._pull(request, options)
  File "/Users/daspecster/.virtualenvs/gct/lib/python2.7/site-packages/google/gax/api_callable.py", line 481, in inner
    return api_caller(api_call, this_settings, request)
  File "/Users/daspecster/.virtualenvs/gct/lib/python2.7/site-packages/google/gax/api_callable.py", line 469, in base_caller
    return api_call(*args)
  File "/Users/daspecster/.virtualenvs/gct/lib/python2.7/site-packages/google/gax/api_callable.py", line 434, in inner
    errors.create_error('RPC failed', cause=exception))
  File "/Users/daspecster/.virtualenvs/gct/lib/python2.7/site-packages/google/gax/api_callable.py", line 430, in inner
    return a_func(*args, **kwargs)
  File "/Users/daspecster/.virtualenvs/gct/lib/python2.7/site-packages/google/gax/api_callable.py", line 64, in inner
    return a_func(*updated_args, **kwargs)
  File "/Users/daspecster/.virtualenvs/gct/lib/python2.7/site-packages/grpc/_channel.py", line 481, in __call__
    return _end_unary_response_blocking(state, False, deadline)
  File "/Users/daspecster/.virtualenvs/gct/lib/python2.7/site-packages/grpc/_channel.py", line 432, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
google.gax.errors.GaxError: GaxError(RPC failed, caused by <_Rendezvous of RPC that terminated with (StatusCode.DEADLINE_EXCEEDED, Deadline Exceeded)>)
E1121 11:08:01.032859000 140736417121216 network_status_tracker.c:48] Memory leaked as all network endpoints were not shut down

With gRPC disabled:

$ GOOGLE_CLOUD_DISABLE_GRPC=true python test_pubsub_padding.py
[]
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Nov 21, 2016

Copy link
Copy Markdown
Contributor

I didn't want it to be true, so I stripped out our library and just made low(ish)-level requests with each transport: https://gist.github.com/dhermes/ac47b7b6eebfd46febbd9ee3d824436d

Unfortunately it IS true. The HTTP surface returns a 200 and the gRPC surface returns with an error set to DEADLINE_EXCEEDED.

After confirming this sad "contradiction", I now agree with @tseaver that we should wrap the DEADLINE_EXCEEDED and just return whatever the equivalent to an empty result set is.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Nov 21, 2016

Copy link
Copy Markdown
Contributor

60s to wait for a timeout is a long time, but I feel like if we do make this assumption (i.e. that the surfaces differ), then we should bake that assumption into the system tests, so we can quickly fix it if the assumption ceases to be true.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes dhermes mentioned this pull request Nov 22, 2016
Ignore pubsub timeout errors GoogleCloudPlatform/psq#20
Closed
@googlebot

googlebot commented Nov 22, 2016

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@googlebot googlebot removed the cla: yes This human has signed the Contributor License Agreement. label Nov 22, 2016
@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Nov 22, 2016
@daspecster
daspecster force-pushed the add-gateway-timeout-to-pubsub-pull branch 2 times, most recently from 84c04a4 to 724c428 Compare November 22, 2016 19:25
@googlebot

googlebot commented Nov 22, 2016

Copy link
Copy Markdown

CLAs look good, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Nov 22, 2016
@daspecster daspecster added the PR: Needs to be squashed label Nov 22, 2016
dhermes
dhermes reviewed Nov 23, 2016
View reviewed changes

@dhermes dhermes left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need an extra unit test to check the branch I added (i.e. we only suppress the DEADLINE_EXCEEDED if return immediately was false)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pubsub/google/cloud/pubsub/_gax.py Outdated
except GaxError as exc:
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
raise NotFound(subscription_path)
if exc_to_code(exc.cause) == StatusCode.DEADLINE_EXCEEDED:

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster
daspecster force-pushed the add-gateway-timeout-to-pubsub-pull branch from f18e454 to c9c00b7 Compare November 23, 2016 22:18
@daspecster

daspecster commented Nov 23, 2016

Copy link
Copy Markdown
Contributor Author

Squashed!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster daspecster removed the PR: Needs to be squashed label Nov 23, 2016
dhermes
dhermes reviewed Nov 23, 2016
View reviewed changes
Comment thread pubsub/google/cloud/pubsub/_gax.py Outdated
code = exc_to_code(exc.cause)
if code == StatusCode.NOT_FOUND:
raise NotFound(subscription_path)
elif exc_to_code(exc.cause) == StatusCode.DEADLINE_EXCEEDED:

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daspecster
Add GatewayTimeout exception to pubsub subscription pull.
892e34e
@daspecster
daspecster force-pushed the add-gateway-timeout-to-pubsub-pull branch from c9c00b7 to 892e34e Compare November 23, 2016 22:23
dhermes
dhermes approved these changes Nov 23, 2016
View reviewed changes
@daspecster
daspecster merged commit 8001d45 into googleapis:master Nov 24, 2016
@daspecster
daspecster deleted the add-gateway-timeout-to-pubsub-pull branch November 24, 2016 01:45
@daspecster daspecster mentioned this pull request Nov 24, 2016
subscription pull deadline exceeded #2574
Closed
@dhermes dhermes mentioned this pull request Dec 9, 2016
Update versions for mega-release. #2846
Merged
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
@daspecster
Merge pull request googleapis#2576 from daspecster/add-gateway-timeou…
2ad06a8
…t-to-pubsub-pull

Add gateway timeout to pubsub pull
@theacodes theacodes unassigned dhermes Sep 28, 2018
ohmayr pushed a commit that referenced this pull request Mar 13, 2026
@daniel-sanche
chore: librarian release pull request: 20260309T132416Z (#2576)
dc2a418
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@dhermes dhermes dhermes approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@tseaver tseaver

Labels

api: pubsub Issues related to the Pub/Sub API. backend cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@daspecster @dhermes @tseaver @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.