-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-16852. Skip KeyProviderCache shutdown hook registration if already shutting down #5160
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
Conversation
@xkrogen Can you give a review? 😄 |
💔 -1 overall
This message was automatically generated. |
@xinglin curious to know, did you observe any connection leak b/w KMS and NN here when prelaunch is failed..? how does this will help closing the connection.? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back in Hadoop 2.1.0, HDFS-4841 was added which made it possible to instantiate a FileSystem
object inside of a shutdown hook. There are valid situations where this happens, as evidenced by both HDFS-4841 and SPARK-3900.
The logic being changed in this PR was added only in March 2022 as part of HDFS-16518. The change has been released ONLY in 2.10.2, since neither 3.3.5 nor 3.4.0 have been released at this time. This is likely why we are not (yet) seeing other complaints about this issue, since usage of 2.10.2 may be limited.
The biggest problem here is that this blocks creation of any HDFS client in a shutdown hook, regardless of whether or not you're using the KeyProviderCache
, since the shutdown hook is added in the constructor and a KeyProviderCache
is always initialized as part of ClientContext
initialization:
Line 176 in 60e0fe8
this.keyProviderCache = new KeyProviderCache( |
Regarding concern about leaks, if desired, we can add a flag in the KeyProviderCache
like finalizerInitialized
and refuse to serve KeyProvider
instances if initialization was unsuccessful. This at least makes it possible to initialize/use FS objects that don't make use of the cache, limiting the problem scope. I don't have enough context on HDFS-16518 to say if this is necessary or not.
cc @li-leyang @omalley @ibuenros since you were all involved in HDFS-16518.
...p-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/KeyProviderCache.java
Outdated
Show resolved
Hide resolved
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
I think the original intention was to explicitly invalidate KeyProviderCache at each DFSClient close(For KMS use case). We need to explicit close this singleton cache at DFSClient close hence this was added in JVM ShutdownHook. |
LGTM |
Right now we skip adding the shutdown hook regardless of whether or not If it's not, we can make it so that |
@li-leyang you gave a LGTM. Do you think the current change is good enough? |
I think this should be fine. The KeyProviderCache also has expiration mechanism so it will get cleared eventually. This was introduced to tackle a bug where each DFSClient instance closes a global KeyProviderCache. |
Yetus is failing the I am merging to trunk. Thanks for the contribution @xinglin and the review @li-leyang ! |
Backported to branch-3.3 and branch-2.10 as well; all of the places that HDFS-16518 landed. |
…dy shutting down (apache#5160) Signed-off-by: Erik Krogen <xkrogen@apache.org>
…dy shutting down (apache#5160) Signed-off-by: Erik Krogen <xkrogen@apache.org> (cherry picked from commit f7bdf6c) (cherry picked from commit d43fa95) ACLOVERRIDE
Description of PR
Check whether shutdown is in-progress before registering a new shutdown. Registering a shutdown hook during shutdown is not supported. For more details, please check HDFS-16852.
How was this patch tested?
mvn test -Dtest="TestKeyProviderCache"
For code changes:
LICENSE
,LICENSE-binary
,NOTICE-binary
files?