Repository navigation
fix(bigtable): handle empty SessionPoolConfiguration in SessionPoolImpl and PoolSizer - #14912
igorbernstein2 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds robust handling for empty or disabled session pool configurations in the Google Cloud Bigtable client. Key changes include preventing division-by-zero errors in PoolSizer when pendingVRpcsPerSession is zero, updating SessionPoolImpl to properly cancel retry futures and close active sessions when the configuration is reset to default, and adding corresponding unit tests. The review feedback correctly identifies a compilation error in SessionPoolImpl.java where Future.cancel() is called without its required boolean argument, and suggests using cancel(false) instead.
| if (newConfig.equals( | ||
| SessionClientConfiguration.SessionPoolConfiguration.getDefaultInstance())) { | ||
| if (retryCreateSessionFuture != null) { | ||
| retryCreateSessionFuture.cancel(); |
There was a problem hiding this comment.
In Java, Future.cancel (and its sub-interfaces like ScheduledFuture) requires a boolean argument (mayInterruptIfRunning) to specify whether the executing thread should be interrupted. Calling cancel() with no arguments will result in a compilation error. Please use cancel(false) instead.
| retryCreateSessionFuture.cancel(); | |
| retryCreateSessionFuture.cancel(false); |
Summary
When
session_load == 0across all scopes,ClientConfigurationManager.normalizeConfigclearssession_configuration, resulting in an emptySessionPoolConfiguration.getDefaultInstance().This change updates
PoolSizerandSessionPoolImplto handle an emptySessionPoolConfigurationcleanly:PoolSizer:pendingVRpcsPerSession > 0ingetScaleDelta()to prevent divide-by-zero (+Infinity->Integer.MAX_VALUEandintoverflow wheninUseCount >= 1).handleGoAwayandhandleSessionClosefromgetScaleDelta() >= 0togetScaleDelta() > 0(sinceonSessionClosing/onSessionClosedalready decrementsexpectedCapacityprior to consultingPoolSizer).SessionPoolImpl&SessionList:maybeScheduleCreateSessionRetry()withbudget.getMaxConcurrentRequest() <= 0so it does not spin on a 1ms retry timer whenbudget == 0.SessionHandle.onSessionClosing()idempotent with respect toexpectedCapacity.newConfigisSessionPoolConfiguration.getDefaultInstance(), cancelsretryCreateSessionFutureand gracefully closes all sessions (CLOSE_SESSION_REASON_DOWNSIZE); whennewConfigis non-empty andpoolState == PoolState.STARTED, scales back up via the pre-start loop.