@@ -2649,28 +2649,26 @@ private void removeLongRunningSessions(
2649
2649
void maintainMultiplexedSession (Instant currentTime ) {
2650
2650
try {
2651
2651
if (options .getUseMultiplexedSession ()) {
2652
- synchronized (lock ) {
2653
- if (currentMultiplexedSessionReference .get ().isDone ()) {
2654
- SessionReference sessionReference = getMultiplexedSessionInstance ();
2655
- if (sessionReference != null
2656
- && isMultiplexedSessionStale (sessionReference , currentTime )) {
2657
- final Instant minExecutionTime =
2658
- multiplexedSessionReplacementAttemptTime .plus (
2659
- multiplexedSessionCreationRetryDelay );
2660
- if (currentTime .isBefore (minExecutionTime )) {
2661
- return ;
2662
- }
2663
- /*
2664
- This will attempt to create a new multiplexed session. if successfully created then
2665
- the existing session will be replaced. Note that there maybe active transactions
2666
- running on the stale session. Hence, it is important that we only replace the reference
2667
- and not invoke a DeleteSession RPC.
2668
- */
2669
- maybeCreateMultiplexedSession (multiplexedMaintainerConsumer );
2670
-
2671
- // update this only after we have attempted to replace the multiplexed session
2672
- multiplexedSessionReplacementAttemptTime = currentTime ;
2652
+ if (currentMultiplexedSessionReference .get ().isDone ()) {
2653
+ SessionReference sessionReference = getMultiplexedSessionInstance ();
2654
+ if (sessionReference != null
2655
+ && isMultiplexedSessionStale (sessionReference , currentTime )) {
2656
+ final Instant minExecutionTime =
2657
+ multiplexedSessionReplacementAttemptTime .plus (
2658
+ multiplexedSessionCreationRetryDelay );
2659
+ if (currentTime .isBefore (minExecutionTime )) {
2660
+ return ;
2673
2661
}
2662
+ /*
2663
+ This will attempt to create a new multiplexed session. if successfully created then
2664
+ the existing session will be replaced. Note that there maybe active transactions
2665
+ running on the stale session. Hence, it is important that we only replace the reference
2666
+ and not invoke a DeleteSession RPC.
2667
+ */
2668
+ maybeCreateMultiplexedSession (multiplexedMaintainerConsumer );
2669
+
2670
+ // update this only after we have attempted to replace the multiplexed session
2671
+ multiplexedSessionReplacementAttemptTime = currentTime ;
2674
2672
}
2675
2673
}
2676
2674
}
0 commit comments