Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDFS-15383. RBF: Add support for router delegation token without watch #2047

Merged
merged 2 commits into from
Jun 23, 2020

Conversation

fengnanli
Copy link
Contributor

Summary:
This patch is targeting improving router's performance
for delegation tokens related operations.
It achieves the goal by removing watchers from router on
tokens since based on our experience. The huge number of
watches inside Zookeeper is degrading Zookeeper's performance
pretty hard. The current limit is about 1.2-1.5 million.

Specific changes:

  1. Explicitly disable the watcher to tokens by not using
    PathChildrenCache or any curator provided cache at all.
  2. Schedule a sync task between router and Zookeeper at
    a configurable interval to make routers sync with their
    token information through Zookeeper.
  3. For token's change, always make sure to change local cache
    first instead of depending on callbacks of the watch event
    when using PathChildrenCache.
    The above three points are trying to make router token cache
    behaves as close as possible to the case when the PathChildrenCache
    is used. The below point handles one corner case.
  4. Before token remover(a background thread) removes token from
    Zookeeper, one router will first make sure this token hasn't
    been renewed by other peers. This happens only when somehow the
    sync failed for this token that router local cache doesn't have
    the corret renewal date (expiry date)

Test Plan:

  1. Add several unit tests covering all common use cases.
  2. Deployed on two machines and performing all tests.
  3. Pressure testing: create production scale number of tokens (100k)
    and monitor the sync latency.

NOTICE

Please create an issue in ASF JIRA before opening a pull request,
and you need to set the title of the pull request which starts with
the corresponding JIRA issue number. (e.g. HADOOP-XXXXX. Fix a typo in YYY.)
For more details, please see https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute

Summary:
This patch is targeting improving router's performance
for delegation tokens related operations.
It achieves the goal by removing watchers from router on
tokens since based on our experience. The huge number of
watches inside Zookeeper is degrading Zookeeper's performance
pretty hard. The current limit is about 1.2-1.5 million.

Specific changes:
1. Explicitly disable the watcher to tokens by not using
   PathChildrenCache or any curator provided cache at all.
2. Schedule a sync task between router and Zookeeper at
   a configurable interval to make routers sync with their
   token information through Zookeeper.
3. For token's change, always make sure to change local cache
   first instead of depending on callbacks of the watch event
   when using PathChildrenCache.
The above three points are trying to make router token cache
behaves as close as possible to the case when the PathChildrenCache
is used. The below point handles one corner case.
4. Before token remover(a background thread) removes token from
   Zookeeper, one router will first make sure this token hasn't
   been renewed by other peers. This happens only when somehow the
   sync failed for this token that router local cache doesn't have
   the corret renewal date (expiry date)

Test Plan:
1. Add several unit tests covering all common use cases.
2. Deployed on two machines and performing all tests.
3. Pressure testing: create production scale number of tokens (100k)
   and monitor the sync latency.
@fengnanli fengnanli changed the title Add support for router delegation token without watch HDFS-15383 Add support for router delegation token without watch Jun 2, 2020
@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 1m 27s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 0m 33s Maven dependency ordering for branch
+1 💚 mvninstall 25m 31s trunk passed
+1 💚 compile 23m 7s trunk passed
+1 💚 checkstyle 3m 10s trunk passed
+1 💚 mvnsite 2m 32s trunk passed
+1 💚 shadedclient 24m 8s branch has no errors when building and testing our client artifacts.
+1 💚 javadoc 1m 50s trunk passed
+0 🆗 spotbugs 1m 31s Used deprecated FindBugs config; considering switching to SpotBugs.
+1 💚 findbugs 4m 2s trunk passed
_ Patch Compile Tests _
+0 🆗 mvndep 0m 25s Maven dependency ordering for patch
+1 💚 mvninstall 1m 36s the patch passed
+1 💚 compile 22m 19s the patch passed
+1 💚 javac 22m 19s the patch passed
-0 ⚠️ checkstyle 3m 11s root: The patch generated 7 new + 80 unchanged - 0 fixed = 87 total (was 80)
+1 💚 mvnsite 2m 24s the patch passed
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
+1 💚 shadedclient 15m 57s patch has no errors when building and testing our client artifacts.
+1 💚 javadoc 1m 34s the patch passed
+1 💚 findbugs 3m 41s the patch passed
_ Other Tests _
-1 ❌ unit 9m 13s hadoop-common in the patch passed.
+1 💚 unit 9m 52s hadoop-hdfs-rbf in the patch passed.
-1 ❌ asflicense 0m 46s The patch generated 1 ASF License warnings.
155m 24s
Reason Tests
Failed junit tests hadoop.security.TestRaceWhenRelogin
Subsystem Report/Notes
Docker ClientAPI=1.40 ServerAPI=1.40 base: https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/1/artifact/out/Dockerfile
GITHUB PR #2047
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient findbugs checkstyle
uname Linux 75faf044bd19 4.15.0-91-generic #92-Ubuntu SMP Fri Feb 28 11:09:48 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality personality/hadoop.sh
git revision trunk / 6288e15
Default Java Private Build-1.8.0_252-8u252-b09-1~18.04-b09
checkstyle https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/1/artifact/out/diff-checkstyle-root.txt
unit https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/1/artifact/out/patch-unit-hadoop-common-project_hadoop-common.txt
Test Results https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/1/testReport/
asflicense https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/1/artifact/out/patch-asflicense-problems.txt
Max. process+thread count 3232 (vs. ulimit of 5500)
modules C: hadoop-common-project/hadoop-common hadoop-hdfs-project/hadoop-hdfs-rbf U: .
Console output https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/1/console
versions git=2.17.1 maven=3.6.0 findbugs=3.1.0-RC1
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

Copy link
Contributor

@Hexiaoqiao Hexiaoqiao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fengnanli for your proposal here.


/**
* Zookeeper based router delegation token store implementation.
*/
public class ZKDelegationTokenSecretManagerImpl extends
ZKDelegationTokenSecretManager<AbstractDelegationTokenIdentifier> {

public static final String ZK_DTSM_ROUTER_TOKEN_SYNC_INTERVAL =
"zk-dt-secret-manager.router.token.sync.interval";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a. It is better to keep the same code style.

  public static final String ZK_DTSM_ROUTER_TOKEN_SYNC_INTERVAL =
      "zk-dt-secret-manager.router.token.sync.interval";

->

  public static final String ZK_DTSM_ROUTER_TOKEN_SYNC_INTERVAL =
      ZK_CONF_PREFIX + "router.token.sync.interval";

b. IMO, this is common improvement, it should not aimed at Router only, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point a) changed.
Point b) this class was brought in as a router delegation support effort and was designed for Router initially, hence I put the router name string inside.

private final ScheduledExecutorService scheduler =
Executors.newSingleThreadScheduledExecutor();

// Local cache of delegation tokens, used for depracating tokens from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depracating -> deprecating?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

throw new IOException(ex);
}
// Store data to currentTokenMap
processTokenAddOrUpdate(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks there are double deserialize operations, it should be better if we can merge them to one IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// 1) add/update tokens to local cache from zk, which is done through
// processTokenAddOrUpdate above
// 2) remove tokens in local cache but not in zk anymore
for (AbstractDelegationTokenIdentifier ident : currentTokens.keySet()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this loop, content of loacalTokenCache is equal to currentTokens right? If that, should we set the currentTokens = localTokenCache directly? Please correct me if wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localTokenCache is a set for tokenIdent, currentTokens is the map to store the actual TokenInformation. We will need to construct all of the TokenInformation to do the swap. And the swap needs to be done in a synchronized block. I think the current way is simpler and following the logic inside its parent class.

@@ -0,0 +1,216 @@
package org.apache.hadoop.hdfs.server.federation.security.token;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lack of license annotation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh.. somehow I missed it. Thanks for pointing out.

@goiri goiri changed the title HDFS-15383 Add support for router delegation token without watch HDFS-15383. RBF: Add support for router delegation token without watch Jun 3, 2020
@Cosss7
Copy link
Contributor

Cosss7 commented Jun 18, 2020

hi~ @fengnanli Are you still here? I think it's a good work and I hope to see it's done.

Or someone can take over this work, e.g me?

@fengnanli
Copy link
Contributor Author

@Cosss7 Thanks for pinging me. I was busy with some other stuff and will start addressing comments soon.

@Cosss7
Copy link
Contributor

Cosss7 commented Jun 19, 2020

@fengnanli Very brilliant work. Expect work to be done. ❤️

@fengnanli
Copy link
Contributor Author

Thanks for the review @Hexiaoqiao ! Have you tested it on your setup?
@goiri Do you mind reviewing this change? Thanks very much!

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 25m 34s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 1m 14s Maven dependency ordering for branch
+1 💚 mvninstall 21m 58s trunk passed
+1 💚 compile 20m 54s trunk passed with JDK Ubuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04
+1 💚 compile 18m 1s trunk passed with JDK Private Build-1.8.0_252-8u252-b09-1~18.04-b09
+1 💚 checkstyle 2m 51s trunk passed
+1 💚 mvnsite 2m 5s trunk passed
+1 💚 shadedclient 20m 45s branch has no errors when building and testing our client artifacts.
-1 ❌ javadoc 0m 37s hadoop-common in trunk failed with JDK Ubuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04.
-1 ❌ javadoc 0m 33s hadoop-hdfs-rbf in trunk failed with JDK Ubuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04.
+1 💚 javadoc 1m 31s trunk passed with JDK Private Build-1.8.0_252-8u252-b09-1~18.04-b09
+0 🆗 spotbugs 1m 18s Used deprecated FindBugs config; considering switching to SpotBugs.
+1 💚 findbugs 3m 23s trunk passed
_ Patch Compile Tests _
+0 🆗 mvndep 0m 21s Maven dependency ordering for patch
+1 💚 mvninstall 1m 22s the patch passed
+1 💚 compile 20m 19s the patch passed with JDK Ubuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04
+1 💚 javac 20m 19s the patch passed
+1 💚 compile 17m 42s the patch passed with JDK Private Build-1.8.0_252-8u252-b09-1~18.04-b09
+1 💚 javac 17m 42s the patch passed
-0 ⚠️ checkstyle 2m 52s root: The patch generated 9 new + 80 unchanged - 0 fixed = 89 total (was 80)
+1 💚 mvnsite 2m 24s the patch passed
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
+1 💚 shadedclient 17m 43s patch has no errors when building and testing our client artifacts.
-1 ❌ javadoc 0m 36s hadoop-common in the patch failed with JDK Ubuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04.
-1 ❌ javadoc 0m 32s hadoop-hdfs-rbf in the patch failed with JDK Ubuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04.
+1 💚 javadoc 1m 33s the patch passed with JDK Private Build-1.8.0_252-8u252-b09-1~18.04-b09
+1 💚 findbugs 3m 50s the patch passed
_ Other Tests _
+1 💚 unit 9m 49s hadoop-common in the patch passed.
-1 ❌ unit 10m 6s hadoop-hdfs-rbf in the patch passed.
+1 💚 asflicense 0m 49s The patch does not generate ASF License warnings.
209m 3s
Reason Tests
Failed junit tests hadoop.hdfs.server.federation.store.TestStateStoreMembershipState
Subsystem Report/Notes
Docker ClientAPI=1.40 ServerAPI=1.40 base: https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/2/artifact/out/Dockerfile
GITHUB PR #2047
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient findbugs checkstyle
uname Linux 7885b472a04f 4.15.0-101-generic #102-Ubuntu SMP Mon May 11 10:07:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality personality/hadoop.sh
git revision trunk / 9821b94
Default Java Private Build-1.8.0_252-8u252-b09-1~18.04-b09
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_252-8u252-b09-1~18.04-b09
javadoc https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/2/artifact/out/branch-javadoc-hadoop-common-project_hadoop-common-jdkUbuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04.txt
javadoc https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/2/artifact/out/branch-javadoc-hadoop-hdfs-project_hadoop-hdfs-rbf-jdkUbuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04.txt
checkstyle https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/2/artifact/out/diff-checkstyle-root.txt
javadoc https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/2/artifact/out/patch-javadoc-hadoop-common-project_hadoop-common-jdkUbuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04.txt
javadoc https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/2/artifact/out/patch-javadoc-hadoop-hdfs-project_hadoop-hdfs-rbf-jdkUbuntu-11.0.7+10-post-Ubuntu-2ubuntu218.04.txt
unit https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/2/artifact/out/patch-unit-hadoop-hdfs-project_hadoop-hdfs-rbf.txt
Test Results https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/2/testReport/
Max. process+thread count 3240 (vs. ulimit of 5500)
modules C: hadoop-common-project/hadoop-common hadoop-hdfs-project/hadoop-hdfs-rbf U: .
Console output https://builds.apache.org/job/hadoop-multibranch/job/PR-2047/2/console
versions git=2.17.1 maven=3.6.0 findbugs=3.1.0-RC1
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@goiri
Copy link
Member

goiri commented Jun 19, 2020

It looks good to me.
@Hexiaoqiao can you provide feedback if you have tested it?

@Hexiaoqiao
Copy link
Contributor

Thanks @fengnanli for your continued works. LGTM, I would like to give +1 from my side.
@goiri I just test this improvement in my test environment but not production cluster. it works fine for me.
Another suggestion, I still think we should consider this as common improvement not only for Router, since it is also effective for KMS and other modules who uses ZK to store DTs. So is it proper to move ZKDelegationTokenSecretManagerImpl class to common sub project? Of course this is not blocked point. cc @goiri @fengnanli @Cosss7 any suggestions?
Thanks @fengnanli again.

@goiri
Copy link
Member

goiri commented Jun 21, 2020

Thanks @Hexiaoqiao for the feedback.
I would make the proposed change for KMS in a separate JIRA.
If nobody has any concerns we can go ahead and merge this.

@fengnanli
Copy link
Contributor Author

Thanks @goiri @Hexiaoqiao @Cosss7 for the review!
We internally have KMS running for some security projects and if anyone is interested in providing the KMS version, let me know the ticket so I can have them testing the code.

@Hexiaoqiao
Copy link
Contributor

@fengnanli @goiri I agree that we can push this improvement ahead and file another JIRA for other modules.

@goiri goiri merged commit 84110d8 into apache:trunk Jun 23, 2020
Xushaohong pushed a commit to Xushaohong/hadoop that referenced this pull request Jul 20, 2022
…ithout watch (apache#2047)

Improving router's performance for delegation tokens related operations. It achieves the goal by removing watchers from router on tokens since based on our experience. The huge number of watches inside Zookeeper is degrading Zookeeper's performance pretty hard. The current limit is about 1.2-1.5 million.
melissayou pushed a commit to melissayou/hadoop that referenced this pull request Oct 23, 2022
apache#2047)

Improving router's performance for delegation tokens related operations. It achieves the goal by removing watchers from router on tokens since based on our experience. The huge number of watches inside Zookeeper is degrading Zookeeper's performance pretty hard. The current limit is about 1.2-1.5 million.
melissayou pushed a commit to melissayou/hadoop that referenced this pull request Nov 5, 2022
apache#2047)

Improving router's performance for delegation tokens related operations. It achieves the goal by removing watchers from router on tokens since based on our experience. The huge number of watches inside Zookeeper is degrading Zookeeper's performance pretty hard. The current limit is about 1.2-1.5 million.
virajith pushed a commit that referenced this pull request Nov 7, 2022
* HDFS-15383. RBF: Add support for router delegation token without watch (#2047)

Improving router's performance for delegation tokens related operations. It achieves the goal by removing watchers from router on tokens since based on our experience. The huge number of watches inside Zookeeper is degrading Zookeeper's performance pretty hard. The current limit is about 1.2-1.5 million.

* HADOOP-17835. Use CuratorCache implementation instead of PathChildrenCache / TreeCache (#3266)

Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
Co-authored-by: lfengnan <lfengnan@uber.com>
Co-authored-by: Viraj Jasani <vjasani@apache.org>
Co-authored-by: Melissa You <myou@myou-mn1.linkedin.biz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants