streamnative / kop

Kafka-on-Pulsar - A protocol handler that brings native Kafka protocol to Apache Pulsar
https://streamnative.io/docs/kop
Apache License 2.0
447 stars 132 forks source link

[BUG] KerberosLogin causes high CPU usage #2032

Closed liudezhi2098 closed 7 months ago

liudezhi2098 commented 7 months ago

Describe the bug

                while (true) {
                    try {
                        reLogin();
                    } catch (LoginException e) {
                        if (retry > 0) {
                            log.warn("[Principal={}]: Error when trying to re-Login, but will retry ", principal, e);
                            retry--;
                            try {
                                Thread.sleep(10 * 1000);
                            } catch (InterruptedException ie) {
                                log.error("[Principal={}]: Interrupted during login retry after LoginException:",
                                        principal, e);
                                return;
                            }
                     }
              while (true) {
                        try {
                            if (log.isDebugEnabled()) {
                                log.debug("[Principal={}]: Running ticket cache refresh command: {} {}",
                                        principal, SASL_KERBEROS_KINIT_CMD, kinitArgs);
                            }
                            Shell.execCommand(SASL_KERBEROS_KINIT_CMD, kinitArgs);
                        } catch (IOException e) {
                            if (retry > 0) {
                                log.warn("[Principal={}]: Error when trying to re-Login, but will retry.",
                                        principal, e);
                                retry--;
                                try {
                                    Thread.sleep(10 * 1000);
                                } catch (InterruptedException ie) {
                                    log.error("[Principal={}]: Interrupted while renewing TGT, exiting Login thread",
                                            principal);
                                    return;
                                }
            }

To Reproduce Steps to reproduce the behavior:

  1. Turn on Kerberos authentication
  2. production and consumption

Expected behavior Reduce cpu utilization.