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

worker exception bug in gearman-ruby-3.0.7 #16

Open
bcber opened this issue Nov 20, 2013 · 0 comments
Open

worker exception bug in gearman-ruby-3.0.7 #16

bcber opened this issue Nov 20, 2013 · 0 comments

Comments

@bcber
Copy link

bcber commented Nov 20, 2013

I'm not good at english, just check POC:

=======================client.rb===========================
client = Gearman::Client.new(servers)
client.option_request("exceptions")
taskset = Gearman::TaskSet.new(client)
task = Gearman::Task.new('test', "test string")
task.retry_count = 3
task.on_exception {|ex| puts "This should never be called" }
taskset.add_task(task)
}
taskset.wait(100)

=======================worker.rb===========================
w = Gearman::Worker.new(servers)
w.add_ability('test') do |data,job|
puts data
data.reverseaaa
end
loop { w.work }

=======================error info===========================
/gems/gearman-ruby-3.0.7/lib/gearman/taskset.rb:287:in `tasks_in_progress': Got unexpected work_data with handle H:xxx:2775 from localhost:4730 (no task by that name) (Gearman::ProtocolError)

login into tasks_in_progress method:

def tasks_in_progress(hostport, handle, remove_task = false)
  js_handle = Util.handle_to_str(hostport, handle)
  tasks = remove_task ? @tasks_in_progress.delete(js_handle) : @tasks_in_progress[js_handle]
  if not tasks
    raise ProtocolError, "Got unexpected work_data with handle #{handle} from #{hostport} (no task by that name)"
  end
  tasks
end

==========================bug==============================
The parameter handle end with \u0000, so @tasks_in_progress.delete(js_handle) is nil. In @tasks_in_progress the record is "localhost:4730//H:localhost:2803", but handle is "localhost:4730//H:localhost:2803\u0000"。

==========================solution===========================
Resolve this like:
add line : handle = handle.chop if handle[-1,1].to_i == 0x00

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

1 participant