fix(spanner): handle errors during stream restart in snapshot (#1471) · googleapis/python-spanner@c066873 · GitHub
Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Commit c066873

Browse files
authored
fix(spanner): handle errors during stream restart in snapshot (#1471)
***Handle errors during stream restart in snapshot*** **Root Cause** When `_restart_on_unavailable` caught a `ServiceUnavailable` or resumable `InternalServerError`, it attempted to re-initialize the iterator immediately within the `except` block. If this re-initialization failed (e.g. due to a persistent transient error), the exception would propagate unhandled, breaking the retry loop. **Fix** This change modifies the logic to reset the iterator to `None` and `continue` the loop, forcing the re-initialization to occur inside the `try` block. This ensures that subsequent errors during restart are properly caught and retried. **Testing** Added unit tests to cover this specific behavior
1 parent 3b1792a commit c066873

2 files changed

Lines changed: 62 additions & 42 deletions

File tree

google/cloud/spanner_v1/snapshot.py

Lines changed: 12 additions & 42 deletions

tests/unit/test_snapshot.py

Lines changed: 50 additions & 0 deletions

0 commit comments

Comments
 (0)