Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 committed Jun 27, 2024
1 parent 6ad748f commit 837ea3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions spanner/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,10 @@ func (p *sessionPool) remove(s *session, isExpire bool) bool {
if s.invalidate() {
// Decrease the number of opened sessions.
p.numOpened--
// Decrease the number of sessions in use.
p.decNumInUseLocked(ctx)
// Decrease the number of sessions in use, only when not from idle list.
if !isExpire {
p.decNumInUseLocked(ctx)
}
p.recordStat(ctx, OpenSessionCount, int64(p.numOpened))
// Broadcast that a session has been destroyed.
close(p.mayGetSession)
Expand Down
8 changes: 7 additions & 1 deletion spanner/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,13 @@ func TestPositiveNumInUseSessions(t *testing.T) {
sh.recycle()
}

for sp.idleList.Len() != 1 {
for true {
sp.mu.Lock()
if sp.idleList.Len() == 1 {
sp.mu.Unlock()
break
}
sp.mu.Unlock()
continue
}
sp.mu.Lock()
Expand Down

0 comments on commit 837ea3b

Please sign in to comment.