googleapis / googleapis/google-cloud-python

A client called `run_in_transaction` be stuck if Spanner is down

未关闭 适合新手
#18,375 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
priority: p2 type: bug
主要语言
Python
星标
5.4k
派生
1.8k
平均合并
3 天 4 小时
30 天内合并 PR
122

描述

### Determine this is the right repository

- [x] I determined this is the correct repository in which to report this bug.

### Summary of the issue

**Context**
When the Spanner is unavailable. If we call [`run_in_transaction`](https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-spanner/google/cloud/spanner_v1/database.py#L1015), the Spanner client will stuck forever.

We believe the [get_session](https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-spanner/google/cloud/spanner_v1/database.py#L1064) should in the try catch block. Otherwise, the `self._local.transaction_running = True` will be forever True.

**Expected Behavior:**
The client will retry when the Spanner DB is back.

**Actual Behavior:**
The client stuck forever.

### API client name and version

_No response_

### Reproduction steps: code

_No response_

### Reproduction steps: supporting files

- Try to create a session when Spanner is unavailable.
- The client will be stuck forever.

### Reproduction steps: actual results

_No response_

### Reproduction steps: expected results

_No response_

### OS & version + platform

_No response_

### Python environment

_No response_

### Python dependencies

_No response_

### Additional context

_No response_

贡献指南

打开贡献指南

调研方向

Start in packages/google-cloud-spanner/google/cloud/spanner_v1/database.py at run_in_transaction and its get_session call. Trace the transaction-running state when session creation fails while Spanner is unavailable, then add coverage for that failure path. Done means the client does not remain stuck and can retry when Spanner becomes available.

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
databases
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
活跃
描述清晰度
基本清楚
新手友好度
72/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。