[ 
https://issues.apache.org/jira/browse/HADOOP-19966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150348#comment-18150348
 ] 

ASF GitHub Bot commented on HADOOP-19966:
-----------------------------------------

pan3793 commented on code in PR #8688:
URL: https://github.com/apache/hadoop/pull/8688#discussion_r4681903693


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java:
##########
@@ -96,6 +98,13 @@ public abstract class 
ZKDelegationTokenSecretManager<TokenIdent extends Abstract
   public static final String ZK_DTSM_TOKEN_WATCHER_ENABLED = ZK_CONF_PREFIX
       + "token.watcher.enabled";
   public static final boolean ZK_DTSM_TOKEN_WATCHER_ENABLED_DEFAULT = true;
+  /**
+   * Bound on the wait for the initial load, per cache (keys, then tokens);
+   * 0 waits indefinitely.
+   */
+  public static final String ZK_DTSM_ZK_CACHE_INIT_TIMEOUT = ZK_CONF_PREFIX
+      + "zkCacheInitTimeout";
+  public static final long ZK_DTSM_ZK_CACHE_INIT_TIMEOUT_DEFAULT = 0;

Review Comment:
   A finite default is fine with me, but I don't have data on how long the 
initial load takes for a large tree, e.g. 1 million tokens, so I can't pick a 
bound that won't fail healthy startups, the case you raised on the 10s timeout. 
Do you have a number from a deployment of that size that we could base the 
default on? Until then, `0` means no limit: the wait logs a WARN every 60s, and 
operators can bound it with `zk-dt-secret-manager.zkCacheInitTimeout`.





> ZKDelegationTokenSecretManager startup cache load races with CuratorCache 
> initialization
> ----------------------------------------------------------------------------------------
>
>                 Key: HADOOP-19966
>                 URL: https://issues.apache.org/jira/browse/HADOOP-19966
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Cheng Pan
>            Priority: Major
>              Labels: pull-request-available
>
> Since HADOOP-17835 (3.4.0), ZKDelegationTokenSecretManager starts its 
> CuratorCache asynchronously and reads it immediately, so loadFromZKCache runs 
> against an empty or partial cache. Token verify/renew/cancel are unaffected 
> because they fall back to ZooKeeper, and the cache listener fills the 
> in-memory map a few seconds later. The lasting effects are:
> * token owner stats (Router getTopTokenRealOwners) are computed from a 
> partial map and never corrected for pre-restart tokens;
> * the root container znode, which carries Curator's default data (the local 
> address), is parsed as a key/token on every startup and logs an ERROR;
> * testNodesLoadedAfterRestart is flaky in CI.
> Fix: wait for CuratorCache initialization (forInitialized) before loading 
> each cache, skip the root container znodes when processing cache events and 
> when streaming the cache, create the root znodes with explicit empty data, 
> and release the caches, counters and Curator client when startThreads() fails.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to