jmettraux / ruote

a ruby workflow engine (dead)
MIT License
496 stars 74 forks source link

JRuby ConcurrencyError #77

Closed mwotton closed 11 years ago

mwotton commented 11 years ago

Is ruote expected to work with JRuby? Very intermittently, I've been getting errors in wait_logger.rb:

fei: engine_id: engine wfid: 20130321-0746-johenoshi-geguteha subid: !binary |- ZTc3ZTA1ZDg3YzZjNGQwZjA1OGZhZmU4YzQ5YjQxY2Q= expid: '0_0' at: '2013-03-21 07:46:14.107000 UTC' class:
ConcurrencyError message: Detected invalid array contents due to unsynchronized modifications with concurrent users trace: - org/jruby/RubyArray.java:1147:in `<<' 
              - "/home/mwotton/.rvm/gems/jruby-head/gems/ruote-2.3.0.1/lib/ruote/log/wait_logger.rb:102:in\ \ `on_msg'" 
              - "/home/mwotton/.rvm/gems/jruby-head/gems/ruote-2.3.0.1/lib/ruote/context.rb:199:in\ \ `notify'" 
              - org/jruby/RubyArray.java:1613:in `each' - "/home/mwotton/.rvm/gems/jruby-head/gems/ruote-2.3.0.1/lib/ruote/context.rb:199:in\ \ `notify'"
              - "/home/mwotton/.rvm/gems/jruby-head/gems/ruote-2.3.0.1/lib/ruote/worker.rb:404:in\ \ `process'" - "/home/mwotton/.rvm/gems/jruby-head/gems/ruote-2.3.0.1/lib/ruote/worker.rb:195:in\ \ `process_msgs'"
              - "/home/mwotton/.rvm/gems/jruby-head/gems/ruote-2.3.0.1/lib/ruote/worker.rb:243:in\ \ `step'" 
              - "/home/mwotton/.rvm/gems/jruby-head/gems/ruote-2.3.0.1/lib/ruote/worker.rb:94:in\ \ `run'" 
               - "/home/mwotton/.rvm/gems/jruby-head/gems/ruote-2.3.0.1/lib/ruote/worker.rb:105:in\ \ `run_in_thread'" 

details: deviations: tree: - sequence - {} - - - init_workitem - {} - [] - - run_command - command: "$f:command" - [] - - subprocess - check_content_subprocess: - [] - - calculate_result - {} - []

looking at line 102:

def on_msg(msg)

  puts(fancy_print(msg, @noisy)) if @noisy

  return if msg['action'] == 'noop'

  @seen << msg
  @log << msg

  while @log.size > @log_max; @log.shift; end
  while @seen.size > @log_max; @seen.shift; end
end

if @seen is being called from multiple threads without a GIL, it can indeed be modified concurrently, as is detailed at http://merbist.com/2011/10/18/data-safety-and-gil-removal/

jmettraux commented 11 years ago

Thanks, much appreciated, I'll look into it ASAP.

jmettraux commented 11 years ago

Danke schoen !

seen commented 11 years ago

@ mentions are fun! :smile:

jmettraux commented 11 years ago

Sorry Sean!

seen commented 11 years ago

No worries, it's not the first time, and it won't be the last! :smiley:

mwotton commented 11 years ago

(I know this is closed already - just wanted to record that this fix did in fact solve my intermittent problem. Cheers!)

jmettraux commented 11 years ago

Cheers!