mchades commented on code in PR #14407:
URL: https://github.com/apache/gravitino/pull/14407#discussion_r4661367422
##########
catalogs/hadoop-common/src/main/java/org/apache/gravitino/catalog/hadoop/fs/HDFSFileSystemProxy.java:
##########
@@ -55,8 +68,37 @@ public class HDFSFileSystemProxy implements
MethodInterceptor {
public static final String GRAVITINO_KEYTAB_FORMAT = "keytabs/gravitino-%s";
private static final String GRAVITINO_ID_KEY = "gravitino.identifier";
+ // The Hadoop properties the login settings may come from.
+ private static final List<String> LOGIN_HADOOP_KEYS =
+ ImmutableList.of(
+ HADOOP_SECURITY_AUTHENTICATION,
+ Constants.HADOOP_SECURITY_PRINCIPAL,
+ Constants.HADOOP_SECURITY_KEYTAB,
+ Constants.HADOOP_KRB5_CONF);
+ // The source hadoopConfiguration sets the authentication type with when it
replaces a value
+ // that refers to a variable.
+ private static final String EXPANDED_AUTHENTICATION_SOURCE =
+ "Gravitino, replacing a value with variables";
+
+ // Keytab files not deleted yet, because their proxy is still open or failed
to delete them on
+ // close. A shutdown hook hands them to File.deleteOnExit, as calling it for
every proxy would
+ // keep every name ever used until the JVM exits.
+ private static final Set<File> LIVE_KEYTAB_FILES =
ConcurrentHashMap.newKeySet();
+ private static final AtomicReference<Thread> KEYTAB_CLEANER = new
AtomicReference<>();
+ // The JDK caches every keytab path it reads until the JVM exits, so a name
is reused once its
+ // file is deleted. The used slots of each identifier and keytab URI,
guarded by the map.
+ private static final Map<String, BitSet> KEYTAB_SLOTS = new HashMap<>();
+ // Tells apart the keytab files of each loaded copy of this class: JVMs that
share a working
+ // directory, and catalog class loaders, each of which keeps its own slots.
+ private static final String JVM_KEYTAB_TOKEN =
UUID.randomUUID().toString().substring(0, 8);
Review Comment:
**[P2] Reuse keytab paths across catalog reloads**
This token changes with each catalog class loader. After [the last catalog
using a loader is
evicted](https://github.com/apache/gravitino/blob/fc820ee12c2e2e382b4b624fe2cac4d6aae14c93/core/src/main/java/org/apache/gravitino/utils/ClassLoaderPool.java#L98-L111),
reopening the same fileset with the same keytab URI creates a new staging
path. Closing the proxy removes the file, but [OpenJDK's process-wide KeyTab
cache](https://github.com/openjdk/jdk17u/blob/jdk-17.0.7-ga/src/java.security.jgss/share/classes/sun/security/krb5/internal/ktab/KeyTab.java#L65-L67)
retains the entry for each path. Repeated idle eviction and reload can
therefore grow the cache even with an unchanged keytab and one open proxy at a
time. Could the reuse strategy cover catalog reloads too?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]