a0x8o / kafka

A high-throughput, distributed, publish-subscribe messaging system
Apache License 2.0
67 stars 171 forks source link

confusing retry behavior of reLogin() function in KerberosLogin class #21

Open ppeter opened 3 years ago

ppeter commented 3 years ago

In the class KerberosLogin (https://github.com/a0x8o/kafka/blob/master/clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosLogin.java) in the while-loop where the method reLogin is called, there is a retry mechanism that I believe does not work as expected:

If the first reLogin() call fails the function waits for 10 seconds an afterwards calls the reLogin() method is called a second time. In the reLogin() method there is a hasSufficientTimeElapsed() check and after 10 seconds this method usually evaluates to false, as the minTimeBeforeRelogin is by default 1 minute and thus much larger than 10 seconds. As minTimeBeforeRelogin is a long variable it is not even possible to set it to e.g. 5 seconds. The only value for minTimeBeforeReloing does not prematurely stop the second reLogin() call is 0.

This retry behavior is in my opinion confusing as the retry effectively has no effect if minTimBeforeRelogin is not set to 0, which is not even the default value.

I suggest to either