Kafka
  1. Kafka
  2. KAFKA-94

KafkaServer can throw a NullPointerException during startup if zookeeper is down

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None

      Description

      Starting up KafkaServer when zookeeper is down can lead to a NullPointerException as shown below. The LogManager throws a ZkTimeoutException from startup if zookeeper is down. This is caught and we call shutdown. socketServer is uninitialized at this point, and hence the NPE. Will upload patch in a bit.

      2011/08/12 00:22:36.194 FATAL [KafkaServer] [pool-2-thread-1] [kafka] java.lang.NullPointerException
      at kafka.server.KafkaServer.shutdown(KafkaServer.scala:98)
      at kafka.server.KafkaServer.startup(KafkaServer.scala:84)
      at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:40)
      at com.linkedin.kafka.KafkaStartable.start(KafkaStartable.java:49)
      at com.linkedin.spring.servlet.ComponentsContextLoaderListener.setServletContextAttributes(ComponentsContextLoaderListener.java:113)
      at com.linkedin.spring.servlet.ComponentsContextLoaderListener.contextInitialized(ComponentsContextLoaderListener.java:50)
      at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:549)
      at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
      at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
      at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
      at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      at com.linkedin.emweb.ContextBasedHandlerImpl.doStart(ContextBasedHandlerImpl.java:123)
      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
      at com.linkedin.emweb.WebappDeployerImpl.start(WebappDeployerImpl.java:324)
      at com.linkedin.emweb.WebappDeployerImpl.deploy(WebappDeployerImpl.java:178)
      at com.linkedin.emweb.StateKeeperWebappDeployer.deploy(StateKeeperWebappDeployer.java:73)
      at com.linkedin.emweb.mbeans.WebappDeployerAdmin.deploy(WebappDeployerAdmin.java:86)
      at com.linkedin.emweb.mbeans.WebappDeployerAdmin$1.call(WebappDeployerAdmin.java:130)
      at com.linkedin.emweb.mbeans.WebappDeployerAdmin$1.call(WebappDeployerAdmin.java:127)
      at com.linkedin.emweb.mbeans.WebappDeployerAdmin$3.call(WebappDeployerAdmin.java:171)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:619)

        Activity

        Joel Koshy created issue -
        Hide
        Joel Koshy added a comment -

        Since the logmanager is also uninitialized, we should check for that as well.

        2011/08/12 00:22:36.191 FATAL [KafkaServer] [pool-2-thread-1] [kafka] org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 300000
        at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:876)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:84)
        at kafka.server.KafkaZooKeeper.startup(KafkaZooKeeper.scala:45)
        at kafka.log.LogManager.<init>(LogManager.scala:86)
        at kafka.server.KafkaServer.startup(KafkaServer.scala:59)
        at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:40)
        at com.linkedin.kafka.KafkaStartable.start(KafkaStartable.java:49)
        at com.linkedin.spring.servlet.ComponentsContextLoaderListener.setServletContextAttributes(ComponentsContextLoaderListener.java:113)
        at com.linkedin.spring.servlet.ComponentsContextLoaderListener.contextInitialized(ComponentsContextLoaderListener.java:50)
        at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:549)
        at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
        at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
        at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
        at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at com.linkedin.emweb.ContextBasedHandlerImpl.doStart(ContextBasedHandlerImpl.java:123)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at com.linkedin.emweb.WebappDeployerImpl.start(WebappDeployerImpl.java:324)
        at com.linkedin.emweb.WebappDeployerImpl.deploy(WebappDeployerImpl.java:178)
        at com.linkedin.emweb.StateKeeperWebappDeployer.deploy(StateKeeperWebappDeployer.java:73)
        at com.linkedin.emweb.mbeans.WebappDeployerAdmin.deploy(WebappDeployerAdmin.java:86)
        at com.linkedin.emweb.mbeans.WebappDeployerAdmin$1.call(WebappDeployerAdmin.java:130)
        at com.linkedin.emweb.mbeans.WebappDeployerAdmin$1.call(WebappDeployerAdmin.java:127)
        at com.linkedin.emweb.mbeans.WebappDeployerAdmin$3.call(WebappDeployerAdmin.java:171)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)

        Show
        Joel Koshy added a comment - Since the logmanager is also uninitialized, we should check for that as well. 2011/08/12 00:22:36.191 FATAL [KafkaServer] [pool-2-thread-1] [kafka] org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 300000 at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:876) at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98) at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:84) at kafka.server.KafkaZooKeeper.startup(KafkaZooKeeper.scala:45) at kafka.log.LogManager.<init>(LogManager.scala:86) at kafka.server.KafkaServer.startup(KafkaServer.scala:59) at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:40) at com.linkedin.kafka.KafkaStartable.start(KafkaStartable.java:49) at com.linkedin.spring.servlet.ComponentsContextLoaderListener.setServletContextAttributes(ComponentsContextLoaderListener.java:113) at com.linkedin.spring.servlet.ComponentsContextLoaderListener.contextInitialized(ComponentsContextLoaderListener.java:50) at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:549) at org.mortbay.jetty.servlet.Context.startContext(Context.java:136) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at com.linkedin.emweb.ContextBasedHandlerImpl.doStart(ContextBasedHandlerImpl.java:123) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) at com.linkedin.emweb.WebappDeployerImpl.start(WebappDeployerImpl.java:324) at com.linkedin.emweb.WebappDeployerImpl.deploy(WebappDeployerImpl.java:178) at com.linkedin.emweb.StateKeeperWebappDeployer.deploy(StateKeeperWebappDeployer.java:73) at com.linkedin.emweb.mbeans.WebappDeployerAdmin.deploy(WebappDeployerAdmin.java:86) at com.linkedin.emweb.mbeans.WebappDeployerAdmin$1.call(WebappDeployerAdmin.java:130) at com.linkedin.emweb.mbeans.WebappDeployerAdmin$1.call(WebappDeployerAdmin.java:127) at com.linkedin.emweb.mbeans.WebappDeployerAdmin$3.call(WebappDeployerAdmin.java:171) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)
        Joel Koshy made changes -
        Field Original Value New Value
        Attachment kafka-94.patch.v1 [ 12490204 ]
        Hide
        Neha Narkhede added a comment -

        +1. Thanks for the patch.

        Show
        Neha Narkhede added a comment - +1. Thanks for the patch.
        Hide
        Jun Rao added a comment -

        Thanks, Joel. Just committed this.

        Show
        Jun Rao added a comment - Thanks, Joel. Just committed this.
        Neha Narkhede made changes -
        Comment [ The behavior of the mirror.topics.whitelist is backwards incompatible. If some users currently have a whitelist setup with the old format (topic1:numPartitions1, topic2:numPartitions2), it is ideal to just rename "embedded.consumer.topics" to "mirror.topics.whitelist". Instead, this change forces those users to change their white-listed topics list to strip off the number of partitions. It would be ideal if the number of partitions is just ignored, with a little warning message. That way the change is backwards compatible.

        If a user just renames "embedded.consumer.topics" to "mirror.topics.whitelist" and leaves the number of partitions, currently the corp replica behavior is to not mirror anything at all. That is unintuitive. ]
        Hide
        Jay Kreps added a comment -

        Should this be closed?

        Show
        Jay Kreps added a comment - Should this be closed?
        Hide
        Joel Koshy added a comment -

        Yes - this has been committed.

        Show
        Joel Koshy added a comment - Yes - this has been committed.
        Joel Koshy made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Jonathan Creasy made changes -
        Link This issue blocks KAFKA-73 [ KAFKA-73 ]
        Jonathan Creasy made changes -
        Link This issue blocks KAFKA-73 [ KAFKA-73 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Joel Koshy
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development