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

Add sample for passing timeout and retry parameters #927

Closed
asthamohta opened this issue Apr 10, 2023 · 1 comment · Fixed by #1107
Closed

Add sample for passing timeout and retry parameters #927

asthamohta opened this issue Apr 10, 2023 · 1 comment · Fixed by #1107
Assignees
Labels
api: spanner Issues related to the googleapis/python-spanner API. priority: p3 Desirable enhancement or fix. May not be included in next release. samples Issues that are directly related to samples.

Comments

@asthamohta
Copy link
Contributor

No description provided.

@product-auto-label product-auto-label bot added api: spanner Issues related to the googleapis/python-spanner API. samples Issues that are directly related to samples. labels Apr 10, 2023
@asthamohta asthamohta added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed api: spanner Issues related to the googleapis/python-spanner API. samples Issues that are directly related to samples. labels Apr 10, 2023
@product-auto-label product-auto-label bot added api: spanner Issues related to the googleapis/python-spanner API. samples Issues that are directly related to samples. labels Apr 10, 2023
@CaliWee
Copy link

CaliWee commented Apr 13, 2023

The documentation for configuring request timeouts is not well documented in Python -
https://cloud.google.com/spanner/docs/custom-timeout-and-retry

It seems that setting a timeout for a request is possible, as it is documented in the SpannerClient class - https://cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.services.spanner.SpannerClient

However, most use cases in the documentation use the Client, Instance, and Database class -
https://cloud.google.com/spanner/docs/reference/libraries#use
https://cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.client.Client

And from the Client, an instance and database class are instantiated to conduct operations.
Personally I have been attempting to utilize the transaction method batch_update -
https://cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.transaction.Transaction#google_cloud_spanner_v1_transaction_Transaction_batch_update

The documentation specifies that you may provide request options to this method, but the only option that is configurable is the Priority of the request.
https://cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.types.RequestOptions

In practice this method seems to have a default timeout of ~30s - Screen Shot 2023-04-13 at 11 30 22 AM

In the database.run_in_transaction method documentation there is a kwarg "timeout_secs", but this is the timeout configuration for the retry behavior and not the request itself. Setting this timeout to 540 does not resolve the request timeout issue.
https://cloud.google.com/python/docs/reference/spanner/latest/google.cloud.spanner_v1.database.Database#google_cloud_spanner_v1_database_Database_run_in_transaction

As a user, it would be really helpful if the documentation were updated wherever possible to help users configure timeouts as the default timeout settings seem to vary between operations and can be limiting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner API. priority: p3 Desirable enhancement or fix. May not be included in next release. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants