Skip to content

fix(bigquery/storage/managedwriter): address panic on client close - #20932

Merged
shollyman merged 2 commits into
googleapis:mainfrom
shollyman:double-close-panic
Nov 18, 2026
Merged

shollyman merged 2 commits into
googleapis:mainfrom
shollyman:double-close-panic

Conversation

@shollyman

@shollyman shollyman commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closing the outer client (not the individual writers or streams) exposes a condition where we attempt to mark a pending write done more than once, which in this case yields a panic due to double-closure of an associated channel within the pending write.

This PR removes the potential markDone that fires when connection selection fails (related to the transport shutdown), making the finalization of the write a responsibility of the caller. For error cases, that corresponds to the processRetry fn, and for success this is handled in the main connRecvProcessor goroutine loop.

This PR also adds tests to assert behavior under this scenario.

Fixes: #20922

Closing the outer client (not the individual writers or streams) exposes
a condition where we attempt to mark a pending write more than once,
which in this case yields a panic due to double-closure of an associated
channel.

This PR removes the potential markDone that fires when connection
selection fails (related to the transport shutdown), making the
finalization of the write a responsibility of the caller.

This PR also adds tests to validate the behavior.
@shollyman
shollyman requested a review from a team as a code owner November 17, 2026 22:51
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the BigQuery API. label Nov 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the call to markDone when selectConn fails in appendWithRetry, delegating the finalization of pending writes to the callers. It also adds a new test, TestManagedStream_PoolCloseWithRetriesCompletesInflight, to verify that in-flight appends are properly finalized without panicking when the connection pool is closed. There are no review comments, and I have no feedback to provide.

@shollyman shollyman added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 17, 2026
@shollyman shollyman changed the title fix(bigquery/storage/managedwrite): address panic on client close fix(bigquery/storage/managedwriter): address panic on client close Nov 18, 2026
@shollyman shollyman removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 18, 2026
@shollyman
shollyman merged commit 7a5e14f into googleapis:main Nov 18, 2026
18 checks passed
@shollyman
shollyman deleted the double-close-panic branch November 18, 2026 17:33
@release-please release-please Bot mentioned this pull request Nov 18, 2026
shollyman pushed a commit that referenced this pull request Nov 25, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>auth: 0.24.5</summary>

##
[0.24.5](auth/v0.24.4...auth/v0.24.5)
(2026-11-25)


### Bug Fixes

* **auth/credentials/downscope:** Update universe resolution
([#20967](#20967))
([16e0475](16e0475))
* **auth:** Add ES256 length validation
([#20949](#20949))
([35958cc](35958cc))
* **auth:** Improve directpath resolution
([#21004](#21004))
([ceeb6a1](ceeb6a1))
</details>

<details><summary>bigquery: 1.86.4</summary>

##
[1.86.4](bigquery/v1.86.3...bigquery/v1.86.4)
(2026-11-25)


### Bug Fixes

* **bigquery/storage/managedwriter:** Address panic on client close
([#20932](#20932))
([7a5e14f](7a5e14f))
</details>

<details><summary>profiler: 0.7.2</summary>

##
[0.7.2](profiler/v0.7.1...profiler/v0.7.2)
(2026-11-25)


### Bug Fixes

* **profiler:** Universe resolution improvements
([#20991](#20991))
([5cec789](5cec789))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the BigQuery API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bigquery/storage/managedwriter: panic "close of closed channel" in Client.Close with write retries enabled

2 participants