Skip to content

KeyError on ZK.new #96

@andremleblanc

Description

@andremleblanc

Ruby: JRuby-1.7.19
Java: 1.8.0_60
ZooKeeper: 3.4.6

Issue:
When calling ZK.new(localhost:2181) I see the below error in my server log. I tried stepping through the code a bit and it looks like the issue is in the prettify_event method when it calls h[:state] = Zookeeper::Constants::STATE_NAMES.fetch(h[:state]) if h[:state]. For some reason, h[:state] is equal to 4 which is not included in Zookeeper::Constants::STATE_NAMES and there is no default value defined for the fetch.

I don't understand the codebase well enough to know why an unexpected value is showing up here and thus don't know what the fix should be.

Interestingly, this error doesn't seem to be affecting any of the functionality I'm currently using (mainly just getting children of nodes and issuing watches on them). It also doesn't show up through irb or rails console, likely because I don't have logging setup to output there.

12:51:00,698 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20) KeyError: key not found: 4
12:51:00,698 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20)    org/jruby/RubyHash.java:1183:in `fetch'
12:51:00,698 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20)    /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:123:in `prettify_event'
12:51:00,698 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20)    org/jruby/RubyKernel.java:1886:in `tap'
12:51:00,698 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20)    /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:120:in `prettify_event'
12:51:00,698 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20)    /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:67:in `dispatch_next_callback'
12:51:00,698 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20)    org/jruby/RubyProc.java:271:in `call'
12:51:00,698 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20)    /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/logger/forwarding_logger.rb:31:in `add'
12:51:00,698 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20)    /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/logger/forwarding_logger.rb:48:in `debug'
12:51:00,705 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20)    /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:67:in `dispatch_next_callback'
12:51:00,706 ERROR [stderr] (Ruby-3-Thread-69: /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:20)    /Users/andreleblanc/.rvm/gems/jruby-1.7.19/gems/zookeeper-1.4.11-java/lib/zookeeper/common.rb:96:in `dispatch_thread_body'

I feel I should mentioned I'm also getting the below warning, though I don't think it's related. I haven't setup any special authentication or ACLs on my server.

12:51:00,683 WARN  [org.apache.zookeeper.client.ZooKeeperSaslClient] (jboss.deployment.unit."aview_jruby-knob.yml".job_scheduler_Worker-2-SendThread(localhost:2181)) Could not login: the client is being asked for a password, but the Zookeeper client code does not currently support obtaining a password from the user. Make sure that the client is configured to use a ticket cache (using the JAAS configuration setting 'useTicketCache=true)' and restart the client. If you still get this message after that, the TGT in the ticket cache has expired and must be manually refreshed. To do so, first determine if you are using a password or a keytab. If the former, run kinit in a Unix shell in the environment of the user who is running this Zookeeper client using the command 'kinit <princ>' (where <princ> is the name of the client's Kerberos principal). If the latter, do 'kinit -k -t <keytab> <princ>' (where <princ> is the name of the Kerberos principal, and <keytab> is the location of the keytab file). After manually refreshing your cache, restart this client. If you continue to see this message after manually refreshing your cache, ensure that your KDC host's clock is in sync with this host's clock.
12:51:00,684 WARN  [org.apache.zookeeper.ClientCnxn] (jboss.deployment.unit."aview_jruby-knob.yml".job_scheduler_Worker-2-SendThread(localhost:2181)) SASL configuration failed: javax.security.auth.login.FailedLoginException: PBOX000070: Password invalid/Password required Will continue connection to Zookeeper server without SASL authentication, if Zookeeper server allows it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions