Skip to content

Commit

Permalink
fix: update max_in_use_session at 10 mins interval
Browse files Browse the repository at this point in the history
  • Loading branch information
surbhigarg92 committed Dec 26, 2024
1 parent 8d295c4 commit cce4419
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,13 @@ void maintainPool() {
this.prevNumSessionsAcquired = SessionPool.this.numSessionsAcquired;
}
Instant currTime = clock.instant();

// Reset the start time for recording the maximum number of sessions in the pool
if (currTime.isAfter(SessionPool.this.lastResetTime.plus(Duration.ofMinutes(10)))) {
SessionPool.this.maxSessionsInUse = SessionPool.this.numSessionsInUse;
SessionPool.this.lastResetTime = currTime;
}

removeIdleSessions(currTime);
// Now go over all the remaining sessions and see if they need to be kept alive explicitly.
keepAliveSessions(currTime);
Expand Down Expand Up @@ -2309,6 +2316,9 @@ enum Position {
@GuardedBy("lock")
private int maxSessionsInUse = 0;

@GuardedBy("lock")
private Instant lastResetTime = Clock.INSTANCE.instant();

@GuardedBy("lock")
private long numSessionsAcquired = 0;

Expand Down

0 comments on commit cce4419

Please sign in to comment.