Skip to content

Commit

Permalink
fix(spanner): call ctx.cancel after stats have been recorded (googlea…
Browse files Browse the repository at this point in the history
…pis#2728)

The cancel() method should be called once all code that is executing in the given
context have finished. In this case, that also means after the stats recording that
uses the same context has finished.

Fixes googleapis#2660
  • Loading branch information
olavloite authored and tritone committed Aug 25, 2020
1 parent cab4945 commit 1c3a082
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spanner/session.go
Expand Up @@ -1501,7 +1501,6 @@ func (hc *healthChecker) worker(i int) {
if ws != nil {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
err := ws.prepareForWrite(ctx)
cancel()
if err != nil {
// Skip handling prepare error, session can be prepared in next
// cycle.
Expand All @@ -1516,6 +1515,7 @@ func (hc *healthChecker) worker(i int) {
hc.pool.mu.Lock()
hc.pool.decNumBeingPreparedLocked(ctx)
hc.pool.mu.Unlock()
cancel()
hc.markDone(ws)
}
rs := getNextForPing()
Expand Down

0 comments on commit 1c3a082

Please sign in to comment.