Skip to content

Commit 1a662e8

Browse files
wangyumzhangshuyan0
authored andcommitted
[SPARK-49300][CORE][3.5] Fix Hadoop delegation token leak when tokenRenewalInterval is not set (apache#552)
Backport from master. ### What changes were proposed in this pull request? Cancel delegation token once they are used in `getTokenRenewalInterval` ### Why are the changes needed? When `tokenRenewalInterval` is not set, HadoopFSDelegationTokenProvider#getTokenRenewalInterval will fetch some tokens and renew them to get a interval value. https://github.com/apache/spark/blob/dd259b0b27841e6dd7c07f8ca3cc05d275863dd5/core/src/main/scala/org/apache/spark/deploy/security/HadoopFSDelegationTokenProvider.scala#L60-L64 These tokens do not call cancel(), resulting in a large number of existing tokens on HDFS not being cleared in a timely manner, causing additional pressure on the HDFS server. ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? manual test ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#47823 from zhangshuyan0/branch-3.5-zsy. Authored-by: zhangshuyan <zhangshuyan@apache.org> Signed-off-by: Chao Sun <chao@openai.com> Co-authored-by: zhangshuyan <zhangshuyan@apache.org>
1 parent b1a62c6 commit 1a662e8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

core/src/main/scala/org/apache/spark/deploy/security/HadoopFSDelegationTokenProvider.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ private[deploy] class HadoopFSDelegationTokenProvider
146146
val tokenKind = token.getKind.toString
147147
val interval = newExpiration - getIssueDate(tokenKind, identifier)
148148
logInfo(s"Renewal interval is $interval for token $tokenKind")
149+
// The token here is only used to obtain renewal intervals. We should cancel it in
150+
// a timely manner to avoid causing additional pressure on the server.
151+
token.cancel(hadoopConf)
149152
interval
150153
}.toOption
151154
}

0 commit comments

Comments
 (0)