Skip to content

Commit 4049d5e

Browse files
ndyakovCopilot
andauthored
Update internal/auth/streaming/pool_hook.go
Co-authored-by: Copilot <[email protected]>
1 parent 19f4080 commit 4049d5e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

internal/auth/streaming/pool_hook.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,15 @@ func (r *ReAuthPoolHook) OnPut(_ context.Context, conn *pool.Conn) (bool, bool,
104104
reAuthFn(err)
105105
return
106106
default:
107-
// Try to acquire: set Usable=false only if Used=false
108-
if !conn.Used.Load() && conn.Usable.CompareAndSwap(true, false) {
109-
acquired = true
107+
// Try to acquire: set Usable=false, then check Used
108+
if conn.Usable.CompareAndSwap(true, false) {
109+
if !conn.Used.Load() {
110+
acquired = true
111+
} else {
112+
// Release Usable and retry
113+
conn.Usable.Store(true)
114+
time.Sleep(time.Millisecond)
115+
}
110116
} else {
111117
time.Sleep(time.Millisecond)
112118
}

0 commit comments

Comments
 (0)