Skip to content

Commit

Permalink
fix(bigquery/storage/managedwriter): faster context failure on send
Browse files Browse the repository at this point in the history
This is a minor PR that accelerates the failure loop for context
expiration cases.  Previously, the connection abstraction would
deal with expired context on the receiver side, and this change
simply checks context before allowing a new append to succeed.

Tests already existed that exhibited this behavior, but were timing
dependent and masked the issue (the receiver would close the connection
fast enough).

Fixes: googleapis#10128
  • Loading branch information
shollyman committed May 14, 2024
1 parent 1320d7d commit e224f77
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bigquery/storage/managedwriter/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ func (co *connection) close() {

// lockingAppend handles a single append request on a given connection.
func (co *connection) lockingAppend(pw *pendingWrite) error {
// If connection context is expired, error.
if err := co.ctx.Err(); err != nil {
return err
}
// Don't both calling/retrying if this append's context is already expired.
if err := pw.reqCtx.Err(); err != nil {
return err
Expand Down

0 comments on commit e224f77

Please sign in to comment.