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

Shutdown the executor service in KubernetesApplicationOperation and prevent NPE #6785

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging {
expireCleanUpTriggerCacheExecutor,
() => {
try {
if (cleanupTerminatedAppInfoTrigger == null) return
cleanupTerminatedAppInfoTrigger.asMap().asScala.foreach {
case (key, _) =>
// do get to trigger cache eviction
Expand Down Expand Up @@ -273,6 +274,16 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging {
Utils.tryLogNonFatalError(client.close())
}
kubernetesClients.clear()

if (expireCleanUpTriggerCacheExecutor != null) {
Copy link
Member

Choose a reason for hiding this comment

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

This may need to be placed before assigning cleanupTerminatedAppInfoTrigger to null.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, we need to invalidate the cache before shutdown the executor.

Copy link
Member Author

Choose a reason for hiding this comment

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

So that, the remaining terminated application can be cleaned before server stop.

Copy link
Member

Choose a reason for hiding this comment

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

The non-null check here is not atomic, so NPE may still occur.

ThreadUtils.shutdown(expireCleanUpTriggerCacheExecutor)
expireCleanUpTriggerCacheExecutor = null
}

if (cleanupCanceledAppPodExecutor != null) {
ThreadUtils.shutdown(cleanupCanceledAppPodExecutor)
cleanupCanceledAppPodExecutor = null
}
}

private class SparkEnginePodEventHandler(kubernetesInfo: KubernetesInfo)
Expand Down
Loading