Repository navigation
fix(spanner): retry additional transient InternalServerError errors #19175
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,8 +32,8 @@ | |
| from google.cloud.aio._cross_sync import CrossSync | ||
| from google.cloud.spanner_v1._helpers import ( | ||
| _augment_error_with_request_id, | ||
| _check_rst_stream_error, | ||
| _drain_stream, | ||
| _is_retryable_internal_error, | ||
| _make_execute_sql_request, | ||
| _make_value_pb, | ||
| _merge_client_context, | ||
|
|
@@ -69,10 +69,6 @@ | |
| TransactionSelector, | ||
| ) | ||
|
|
||
| _STREAM_RESUMPTION_INTERNAL_ERROR_MESSAGES = ( | ||
| "RST_STREAM", | ||
| "Received unexpected EOS on DATA frame from server", | ||
| ) | ||
| _TRANSACTION_BEGIN_TIMEOUT_SECONDS = 30.0 | ||
|
|
||
|
|
||
|
|
@@ -181,30 +177,17 @@ def _restart_on_unavailable( | |
| break | ||
| else: | ||
| stream_finished = True | ||
| except ServiceUnavailable: | ||
| del item_buffer[:] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we removing this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not 'removed'. It is consolidated into one |
||
| request.resume_token = resume_token | ||
| if transaction is not None: | ||
| transaction_selector = transaction._build_transaction_selector_pb() | ||
| request.transaction = transaction_selector | ||
| attempt += 1 | ||
| iterator = None | ||
| continue | ||
| except InternalServerError as exc: | ||
| resumable_error = any( | ||
| ( | ||
| resumable_message in exc.message | ||
| for resumable_message in _STREAM_RESUMPTION_INTERNAL_ERROR_MESSAGES | ||
| ) | ||
| ) | ||
| if not resumable_error: | ||
| except (ServiceUnavailable, InternalServerError) as exc: | ||
| if isinstance(exc, InternalServerError) and ( | ||
| not _is_retryable_internal_error(exc) | ||
| ): | ||
| raise _augment_error_with_request_id(exc, current_request_id) | ||
| del item_buffer[:] | ||
| request.resume_token = resume_token | ||
| if transaction is not None: | ||
| transaction_selector = transaction._build_transaction_selector_pb() | ||
| attempt += 1 | ||
| request.transaction = transaction_selector | ||
| attempt += 1 | ||
| iterator = None | ||
| continue | ||
| except Exception as exc: | ||
|
|
@@ -766,7 +749,7 @@ def attempt_tracking_method(): | |
|
|
||
| response = _retry( | ||
| attempt_tracking_method, | ||
| allowed_exceptions={InternalServerError: _check_rst_stream_error}, | ||
| allowed_exceptions={InternalServerError: _is_retryable_internal_error}, | ||
| ) | ||
| return [partition.partition_token for partition in response.partitions] | ||
|
|
||
|
|
@@ -841,7 +824,7 @@ def attempt_tracking_method(): | |
|
|
||
| response = _retry( | ||
| attempt_tracking_method, | ||
| allowed_exceptions={InternalServerError: _check_rst_stream_error}, | ||
| allowed_exceptions={InternalServerError: _is_retryable_internal_error}, | ||
| ) | ||
| return [partition.partition_token for partition in response.partitions] | ||
|
|
||
|
|
@@ -919,7 +902,7 @@ def before_next_retry(nth_retry, delay_in_seconds): | |
| wrapped_method, | ||
| before_next_retry=before_next_retry, | ||
| allowed_exceptions={ | ||
| InternalServerError: _check_rst_stream_error, | ||
| InternalServerError: _is_retryable_internal_error, | ||
| Aborted: None, | ||
| }, | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.