Skip to content

Commit

Permalink
fix(spanner): call ctx.cancel after stats have been recorded (#2728)
Browse files Browse the repository at this point in the history
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 #2660
  • Loading branch information
olavloite authored Aug 14, 2020
1 parent 983f1bc commit 17d0159
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spanner/session.go
Original file line number Diff line number Diff line change
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 17d0159

Please sign in to comment.