From 774c62a6fa1ac9d8da7eba08ec315ae003089d79 Mon Sep 17 00:00:00 2001 From: rahul yadav Date: Thu, 14 Nov 2024 14:28:20 +0530 Subject: [PATCH] fix(spanner): add safecheck to avoid deadlock when creating multiplex session --- spanner/session.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spanner/session.go b/spanner/session.go index 3804d0aa4fe2..33308e892d59 100644 --- a/spanner/session.go +++ b/spanner/session.go @@ -906,7 +906,11 @@ func (p *sessionPool) createMultiplexedSession() { p.mu.Lock() p.multiplexedSessionCreationError = err p.mu.Unlock() - p.mayGetMultiplexedSession <- true + select { + case p.mayGetMultiplexedSession <- true: + case <-c.ctx.Done(): + return + } continue } p.sc.executeCreateMultiplexedSession(c.ctx, client, p.sc.md, p)