Skip to content
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

duplicate events #2

Open
tsilen opened this issue Jul 23, 2012 · 4 comments
Open

duplicate events #2

tsilen opened this issue Jul 23, 2012 · 4 comments
Assignees

Comments

@tsilen
Copy link

tsilen commented Jul 23, 2012

Getting a znode with :watch => true seems to somehow cause all on_connecting/on_connected/etc events to be subscribed again causing them to fire multiple times.

@slyphon
Copy link
Contributor

slyphon commented Jul 23, 2012

on_connecting, on_connected events are not related to :watch => true, so I'm not really sure how this would happen. Can you provide example code, or at least detailed steps needed to reproduce?

@ghost ghost assigned slyphon Jul 23, 2012
@tsilen
Copy link
Author

tsilen commented Jul 23, 2012

It's strange indeed.

Was able to reproduce it with this example code:

require 'rubygems'
require 'zk-eventmachine'
require 'logger'

ZK.logger = Logger.new(STDOUT)
ZK.logger.level = Logger::INFO
STDOUT.sync = true

def handle_connecting_event(event=nil)
  @zkem.on_connecting(&method(:handle_connecting_event))
  ZK.logger.info "Connecting"
end

def handle_connected_event(event=nil)
  @zkem.on_connected(&method(:handle_connected_event))
  ZK.logger.info "Connected"
end

@zkem = ZK::ZKEventMachine::Client.new("localhost:2181")
@zkem.on_connecting(&method(:handle_connecting_event))
@zkem.on_connected(&method(:handle_connected_event))

EM.run do
  @zkem.connect do
    @zkem.stat('/test', :watch => true)
  end
end

Running that and then stopping and starting zookeeper gives
Connected
Connecting
Connecting
Connected
Connected

If I remove the stat() or set :watch => false, I get Connected -> Connecting -> Connected as expected
If I add another stat() then I get one more duplicate. Same thing with get(), etc.

Changing log level to debug reveals that there actually seem to be duplicate subscriptions that are then fired.

Any ideas?

@slyphon
Copy link
Contributor

slyphon commented Jul 23, 2012

Urf, ok, i'll take a look. This definitely sounds like a bug, I'll work on it a bit and update you.

@slyphon
Copy link
Contributor

slyphon commented Jul 24, 2012

Blah, ok, i just confirmed this, gonna have to dig around, there's nothing jumping out at me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants