-
Notifications
You must be signed in to change notification settings - Fork 312
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
fix(java-client): fix client renew TGT thread leak when request table doesnt exist #1970
fix(java-client): fix client renew TGT thread leak when request table doesnt exist #1970
Conversation
Handle Exception is a good choice. Exception will make the schedule job not schedule again But i am not quite understand the main cause about if you set daemon false, you should shutdown the threadpool when client jvm shutdown. |
I‘ve talked with @Samunroyu offline, the root cause here is we do not have a close method for |
It make sense. I get the case about thread leak. if the pr finish and ci pass, click request , i will review again @Samunroyu |
b91b9f4
to
89d9712
Compare
java-client/src/main/java/org/apache/pegasus/rpc/interceptor/ReplicaSessionInterceptor.java
Show resolved
Hide resolved
...lient/src/main/java/org/apache/pegasus/rpc/interceptor/ReplicaSessionInterceptorManager.java
Show resolved
Hide resolved
java-client/src/main/java/org/apache/pegasus/rpc/interceptor/ReplicaSessionInterceptor.java
Show resolved
Hide resolved
...lient/src/main/java/org/apache/pegasus/rpc/interceptor/ReplicaSessionInterceptorManager.java
Show resolved
Hide resolved
final int CHECK_TGT_INTEVAL_SECONDS = 10; | ||
final ScheduledExecutorService service = | ||
Executors.newSingleThreadScheduledExecutor( | ||
new ThreadFactory() { | ||
@Override | ||
public Thread newThread(Runnable r) { | ||
Thread t = new Thread(r); | ||
Thread t = new Thread(r, "TGT renew for pegasus"); |
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.
Better introduce a unique suffix or prefix, otherwise if there are multiple client you will see multiple threads with the same name.
@@ -96,11 +97,23 @@ public boolean isAuthRequest(final ReplicaSession.RequestEntry entry) { | |||
} | |||
|
|||
private void scheduleCheckTGTAndRelogin() { | |||
Runnable checkTGTAndReLogin = |
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.
Could still use lambda here.
service.scheduleAtFixedRate(
() -> {
try {
checkTGTAndRelogin();
} catch (Exception e) {
logger.warn(
"check TGT and ReLogin kerberos failed , will retry after {} seconds.",
CHECK_TGT_INTEVAL_SECONDS,
e);
}
}
CHECK_TGT_INTEVAL_SECONDS,
CHECK_TGT_INTEVAL_SECONDS,
TimeUnit.SECONDS);
512a098
to
86aaba5
Compare
86aaba5
to
ea19a6d
Compare
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.
thread leak has fixed
final int CHECK_TGT_INTEVAL_SECONDS = 10; | ||
final ScheduledExecutorService service = | ||
Executors.newSingleThreadScheduledExecutor( | ||
new ThreadFactory() { | ||
@Override | ||
public Thread newThread(Runnable r) { | ||
Thread t = new Thread(r); | ||
String timestamp = new SimpleDateFormat("HHmmss").format(new Date()); |
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.
from JDK8 , advise migration to the java.time classes.
String timestamp = LocalTime.now().format(DateTimeFormatter.ofPattern("HHmmss"));
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.
from JDK8 , advise migration to the java.time classes. String timestamp = LocalTime.now().format(DateTimeFormatter.ofPattern("HHmmss"));
ok, i have changed to use java.time.
In the Kerberos environment, java client will check TGT and relogin
kerberos if needed every 10 seconds by a thread. But when client
requests table which doesnt exist will cause threads leak.
The root cause this problem is when Pegasus client close the client
but don't close TGT thread pool.
This patch adds KerberosProtocol close function.