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 — fix: consume part of StreamingResponseIterator to support failure while under a retry context by crwilcox · Pull Request #10206 · googleapis/google-cloud-python

Conversation

@crwilcox

@crwilcox crwilcox commented Jan 24, 2020 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

In the Node.js SDK, there's code that explicitly waits until at least one result has been observed and retries the underlying stream until then. This doesn't handle the case where the connection is interrupted mid-stream but has been good enough to resolve this class of issues. https://github.com/googleapis/nodejs-firestore/blob/master/dev/src/index.ts#L1127

The Firestore Python SDK needs equivalent code to make it resilient to this class of failure.

This PR causes init of the streaming response iterator to consume the first result immediately which will cause the error to occur while under the retry context. Once the iterator is created it is returned and future access is no longer in a retry context.

Sorry, something went wrong.

Uh oh!

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

All reactions
@crwilcox
fix: consume part of StreamingResponseIterator to support failure whi…
acd79db
…le under retry
@crwilcox
crwilcox requested a review from busunkim96 as a code owner January 24, 2020 22:50
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 24, 2020
@crwilcox crwilcox added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jan 24, 2020
schmidt-sebastian
schmidt-sebastian reviewed Jan 24, 2020
View reviewed changes
Comment thread api_core/google/api_core/grpc_helpers.py
try:
self._first_result = six.next(self._wrapped)
self._stored_first_result = True
except StopIteration:

@schmidt-sebastian schmidt-sebastian Jan 24, 2020

Copy link
Copy Markdown

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.

Will this work for the WatchStream? For Watch, the client has to send the first request. We will not receive a response until after this request has been processed.

Sorry, something went wrong.

Uh oh!

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

All reactions

@crwilcox crwilcox Jan 24, 2020

Copy link
Copy Markdown
Contributor Author

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.

Watch uses ResumableBidiRpc and has its own way of managing recovery. This will have an effect on things like query though.

Sorry, something went wrong.

Uh oh!

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

All reactions
tseaver
tseaver previously requested changes Jan 24, 2020
View reviewed changes

@tseaver tseaver 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.

I would use only a single instance variable here, and arrange to set / clear it atomically.

Sorry, something went wrong.

Uh oh!

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

crwilcox reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@crwilcox
fix: move to not having a flag for first result
2186441
@crwilcox

crwilcox commented Jan 24, 2020

Copy link
Copy Markdown
Contributor Author

NOTE: 3 tests look to need refactoring, also should likely improve coverage given this new behavior.

All reactions

Sorry, something went wrong.

Uh oh!

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

@crwilcox
fix: fix tests
1c36fde
crwilcox
crwilcox commented Jan 27, 2020
View reviewed changes
Comment thread api_core/google/api_core/grpc_helpers.py
# to retrieve the first result, in order to fail, in order to trigger a retry.
try:
self._stored_first_result = six.next(self._wrapped)
except TypeError:

@crwilcox crwilcox Jan 27, 2020

Copy link
Copy Markdown
Contributor Author

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.

@tseaver Under test we have a non-iterable. While it is odd that you would call this without it does seem possible? So added a guard here

Sorry, something went wrong.

Uh oh!

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

All reactions
crwilcox added 3 commits January 27, 2020 13:23
@crwilcox
fix: lint adjust
d2271dd
@crwilcox
fix: add unit test
49fc431
@crwilcox
fix: add unit test for failure in iteration
135d9c0
@crwilcox crwilcox changed the title fix: consume part of StreamingResponseIterator to support failure while under a retry context. fix: consume part of StreamingResponseIterator to support failure while under a retry context Jan 27, 2020
@crwilcox
fix: typo in comment
0f77cb5
@crwilcox crwilcox removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jan 27, 2020
busunkim96
busunkim96 approved these changes Jan 29, 2020
View reviewed changes
@plamut plamut added the api: core label Jan 29, 2020
@crwilcox
crwilcox dismissed tseaver’s stale review January 30, 2020 22:35

resolving

@crwilcox
crwilcox merged commit 7c87dab into googleapis:master Jan 30, 2020
This was referenced Jan 31, 2020
[CHANGE ME] Re-generated automl to pick up changes in the API or client library generator. #10285
Closed
[CHANGE ME] Re-generated bigquery_datatransfer to pick up changes in the API or client library generator. #10286
Closed
[CHANGE ME] Re-generated bigtable to pick up changes in the API or client library generator. #10287
Closed
[CHANGE ME] Re-generated billingbudgets to pick up changes in the API or client library generator. #10288
Closed
[CHANGE ME] Re-generated cloudbuild to pick up changes in the API or client library generator. #10289
Closed
[CHANGE ME] Re-generated datacatalog to pick up changes in the API or client library generator. #10290
Closed
[CHANGE ME] Re-generated firestore to pick up changes in the API or client library generator. #10291
Closed
[CHANGE ME] Re-generated grafeas to pick up changes in the API or client library generator. #10292
Closed
[CHANGE ME] Re-generated iot to pick up changes in the API or client library generator. #10293
Closed
[CHANGE ME] Re-generated language to pick up changes in the API or client library generator. #10294
Closed
This was referenced Feb 4, 2020
[CHANGE ME] Re-generated dataproc to pick up changes in the API or client library generator. #10329
Closed
[CHANGE ME] Re-generated grafeas to pick up changes in the API or client library generator. #10330
Closed
[CHANGE ME] Re-generated kms to pick up changes in the API or client library generator. #10331
Closed
[CHANGE ME] Re-generated language to pick up changes in the API or client library generator. #10332
Closed
[CHANGE ME] Re-generated monitoring to pick up changes in the API or client library generator. #10333
Closed
[CHANGE ME] Re-generated oslogin to pick up changes in the API or client library generator. #10334
Closed
[CHANGE ME] Re-generated phishingprotection to pick up changes in the API or client library generator. #10335
Closed
[CHANGE ME] Re-generated tasks to pick up changes in the API or client library generator. #10336
Closed
[CHANGE ME] Re-generated dataproc to pick up changes in the API or client library generator. #10339
Closed
[CHANGE ME] Re-generated grafeas to pick up changes in the API or client library generator. #10340
Closed
[CHANGE ME] Re-generated iot to pick up changes in the API or client library generator. #10341
Closed
[CHANGE ME] Re-generated irm to pick up changes in the API or client library generator. #10342
Closed
[CHANGE ME] Re-generated kms to pick up changes in the API or client library generator. #10343
Closed
[CHANGE ME] Re-generated language to pick up changes in the API or client library generator. #10344
Closed
[CHANGE ME] Re-generated monitoring to pick up changes in the API or client library generator. #10345
Closed
[CHANGE ME] Re-generated dataproc to pick up changes in the API or client library generator. #10349
Closed
[CHANGE ME] Re-generated grafeas to pick up changes in the API or client library generator. #10350
Closed
[CHANGE ME] Re-generated irm to pick up changes in the API or client library generator. #10351
Closed
[CHANGE ME] Re-generated oslogin to pick up changes in the API or client library generator. #10352
Closed
[CHANGE ME] Re-generated phishingprotection to pick up changes in the API or client library generator. #10353
Closed
[CHANGE ME] Re-generated tasks to pick up changes in the API or client library generator. #10354
Closed
[CHANGE ME] Re-generated asset to pick up changes in the API or client library generator. #10359
Closed
[CHANGE ME] Re-generated grafeas to pick up changes in the API or client library generator. #10360
Closed
[CHANGE ME] Re-generated language to pick up changes in the API or client library generator. #10361
Closed
[CHANGE ME] Re-generated oslogin to pick up changes in the API or client library generator. #10362
Closed
[CHANGE ME] Re-generated recommender to pick up changes in the API or client library generator. #10363
Closed
[CHANGE ME] Re-generated tasks to pick up changes in the API or client library generator. #10364
Closed
@schmidt-sebastian schmidt-sebastian mentioned this pull request Mar 18, 2026
Stream retries googleapis/google-cloud-node#7802
Open
@crwilcox crwilcox mentioned this pull request May 19, 2020
Resolve Incompatibility with API Core >= 1.17.0 googleapis/python-pubsub#93
Closed
parthea pushed a commit that referenced this pull request Nov 24, 2025
@crwilcox
fix: consume part of StreamingResponseIterator to support failure whi…
4aee967
…le under a retry context (#10206)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

3 more reviewers
@schmidt-sebastian schmidt-sebastian schmidt-sebastian left review comments
@busunkim96 busunkim96 busunkim96 approved these changes
@tseaver tseaver tseaver left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

api: core 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.

6 participants

@crwilcox @tseaver @busunkim96 @schmidt-sebastian @plamut @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.