From 6fe8b0c5f1f0b0821524f6c20a283e1d6d37308f Mon Sep 17 00:00:00 2001 From: Dave Marion Date: Thu, 9 Jan 2025 14:13:01 -0500 Subject: [PATCH] Modified SessionManager to recognize session idle property updates (#5239) Reverted changes in #4780, which marked the properties as not mutable. Passed the ServerContext to the sweep method instead of the property values. The property values are resolved at sweep method execution time. Closes #4723 --- .../apache/accumulo/core/conf/Property.java | 3 +-- .../tserver/session/SessionManager.java | 18 +++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/conf/Property.java b/core/src/main/java/org/apache/accumulo/core/conf/Property.java index 981799f6d0d..942dfeea456 100644 --- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java +++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java @@ -1898,8 +1898,7 @@ public static boolean isValidTablePropertyKey(String key) { COMPACTOR_MINTHREADS_TIMEOUT, // others - TSERV_NATIVEMAP_ENABLED, TSERV_SCAN_MAX_OPENFILES, MANAGER_RECOVERY_WAL_EXISTENCE_CACHE_TIME, - TSERV_SESSION_MAXIDLE, TSERV_UPDATE_SESSION_MAXIDLE); + TSERV_NATIVEMAP_ENABLED, TSERV_SCAN_MAX_OPENFILES, MANAGER_RECOVERY_WAL_EXISTENCE_CACHE_TIME); /** * Checks if the given property may be changed via Zookeeper, but not recognized until the restart diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java index d1bf4d6f8cf..0726c1997cb 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java @@ -70,22 +70,15 @@ public class SessionManager { private static final SecureRandom random = new SecureRandom(); private final ConcurrentMap sessions = new ConcurrentHashMap<>(); - private final long maxIdle; - private final long maxUpdateIdle; private final BlockingQueue deferredCleanupQueue = new ArrayBlockingQueue<>(5000); private final Long expiredSessionMarker = (long) -1; - private final AccumuloConfiguration aconf; private final ServerContext ctx; private volatile LongConsumer zombieCountConsumer = null; public SessionManager(ServerContext context) { this.ctx = context; - this.aconf = context.getConfiguration(); - maxUpdateIdle = aconf.getTimeInMillis(Property.TSERV_UPDATE_SESSION_MAXIDLE); - maxIdle = aconf.getTimeInMillis(Property.TSERV_SESSION_MAXIDLE); - - Runnable r = () -> sweep(maxIdle, maxUpdateIdle); - + long maxIdle = ctx.getConfiguration().getTimeInMillis(Property.TSERV_SESSION_MAXIDLE); + Runnable r = () -> sweep(ctx); ThreadPools.watchCriticalScheduledTask(context.getScheduledExecutor().scheduleWithFixedDelay(r, 0, Math.max(maxIdle / 2, 1000), TimeUnit.MILLISECONDS)); } @@ -107,7 +100,7 @@ public long createSession(Session session, boolean reserve) { } public long getMaxIdleTime() { - return maxIdle; + return ctx.getConfiguration().getTimeInMillis(Property.TSERV_SESSION_MAXIDLE); } /** @@ -309,7 +302,10 @@ private void cleanup(Session session) { cleanup(deferredCleanupQueue, session); } - private void sweep(final long maxIdle, final long maxUpdateIdle) { + private void sweep(final ServerContext context) { + final AccumuloConfiguration conf = context.getConfiguration(); + final long maxUpdateIdle = conf.getTimeInMillis(Property.TSERV_UPDATE_SESSION_MAXIDLE); + final long maxIdle = conf.getTimeInMillis(Property.TSERV_SESSION_MAXIDLE); List sessionsToCleanup = new LinkedList<>(); Iterator iter = sessions.values().iterator(); while (iter.hasNext()) {