This is an automated email from the ASF dual-hosted git repository. kturner pushed a commit to branch 2.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push: new b3ec422ba7 invalidates config cache and retries when classloader context not found (#4990) b3ec422ba7 is described below commit b3ec422ba764643c5e5da819ed2d5106dcf7490c Author: Keith Turner <ktur...@apache.org> AuthorDate: Thu Oct 17 16:49:53 2024 -0400 invalidates config cache and retries when classloader context not found (#4990) When a new classloader context is set and then used its possible the config change has not propagated to all servers by the time a scan attempts to use the context. This change invalidates the config cache and retries when when a context is not found. --- .../classloader/DefaultContextClassLoaderFactory.java | 7 ++++--- .../start/classloader/vfs/AccumuloVFSClassLoader.java | 6 ++++-- .../accumulo/start/classloader/vfs/ContextManager.java | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java b/core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java index 152c2b932c..19a8d38579 100644 --- a/core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java +++ b/core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java @@ -58,15 +58,16 @@ public class DefaultContextClassLoaderFactory implements ContextClassLoaderFacto } Supplier<Map<String,String>> contextConfigSupplier = () -> accConf.getAllPropertiesWithPrefix(VFS_CONTEXT_CLASSPATH_PROPERTY); - setContextConfig(contextConfigSupplier); + setContextConfig(contextConfigSupplier, accConf::invalidateCache); LOG.debug("ContextManager configuration set"); startCleanupThread(accConf, contextConfigSupplier); } @SuppressWarnings("deprecation") - private static void setContextConfig(Supplier<Map<String,String>> contextConfigSupplier) { + private static void setContextConfig(Supplier<Map<String,String>> contextConfigSupplier, + Runnable contextConfigInvalidator) { org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader - .setContextConfig(contextConfigSupplier); + .setContextConfig(contextConfigSupplier, contextConfigInvalidator); } private static void startCleanupThread(final AccumuloConfiguration conf, diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java index d7626025e7..c75b931b87 100644 --- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java +++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java @@ -398,8 +398,10 @@ public class AccumuloVFSClassLoader { } } - public static void setContextConfig(Supplier<Map<String,String>> contextConfigSupplier) { - var config = new ContextManager.DefaultContextsConfig(contextConfigSupplier); + public static void setContextConfig(Supplier<Map<String,String>> contextConfigSupplier, + Runnable contextConfigInvalidator) { + var config = + new ContextManager.DefaultContextsConfig(contextConfigSupplier, contextConfigInvalidator); try { getContextManager().setContextConfig(config); } catch (IOException e) { diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java index c57c38c4c0..ad17c5e8a4 100644 --- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java +++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java @@ -118,10 +118,12 @@ class ContextManager { public static class DefaultContextsConfig implements ContextsConfig { private final Supplier<Map<String,String>> vfsContextClasspathPropertiesProvider; + private final Runnable contextConfigInvalidator; - public DefaultContextsConfig( - Supplier<Map<String,String>> vfsContextClasspathPropertiesProvider) { + public DefaultContextsConfig(Supplier<Map<String,String>> vfsContextClasspathPropertiesProvider, + Runnable contextConfigInvalidator) { this.vfsContextClasspathPropertiesProvider = vfsContextClasspathPropertiesProvider; + this.contextConfigInvalidator = contextConfigInvalidator; } @Override @@ -133,7 +135,14 @@ class ContextManager { String uris = props.get(prop); if (uris == null) { - return null; + // maybe the property was set but has not propagated, so invalidate the config to force a + // reread + contextConfigInvalidator.run(); + props = vfsContextClasspathPropertiesProvider.get(); + uris = props.get(prop); + if (uris == null) { + return null; + } } String delegate = props.get(prop + ".delegation");