Actors not executing reliably / dying

28 views
Skip to first unread message

Tim Linquist

unread,
Sep 2, 2016, 8:11:41 PM9/2/16
to Celluloid
I have a very simple test here to test out celluloid. I should see a log message for each async.fetch invocation. I however, never see a number near it. 

Sometimes, the actors get part way through before they all start dying until all are gone. Sometimes there will be no errors but the log lines never
match up to the # of calls to async.fetch. If I reduce the # of calls to 500 I am unable to reproduce the "dead" actor issue in the log excerpt. If I leave the #
of calls at 1k but reduce the pool size they still die reliably.

Am I doing something wrong here? Is 0.17.3 not stable?

Code and logs below

Celluloid version: 0.17.3,
OS: Mac OS X Yosemite 10.10.5

421 I, [2016-09-02T16:54:15.082910 #13978]  INFO -- : fetched 420
422 I, [2016-09-02T16:54:15.082972 #13978]  INFO -- : fetched 421
423 I, [2016-09-02T16:54:15.083034 #13978]  INFO -- : fetched 422
424 I, [2016-09-02T16:54:15.083093 #13978]  INFO -- : fetched 423
425 I, [2016-09-02T16:54:15.083155 #13978]  INFO -- : fetched 424
426 I, [2016-09-02T16:54:15.083216 #13978]  INFO -- : fetched 425
427 I, [2016-09-02T16:54:15.083277 #13978]  INFO -- : fetched 426
428 I, [2016-09-02T16:54:15.083340 #13978]  INFO -- : fetched 427
429 I, [2016-09-02T16:54:15.113703 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
430 I, [2016-09-02T16:54:15.122618 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
431 I, [2016-09-02T16:54:15.122700 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
432 I, [2016-09-02T16:54:15.122742 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
433 I, [2016-09-02T16:54:15.122778 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
434 I, [2016-09-02T16:54:15.122812 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
435 I, [2016-09-02T16:54:15.122847 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
436 I, [2016-09-02T16:54:15.122880 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
437 I, [2016-09-02T16:54:15.122912 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
438 I, [2016-09-02T16:54:15.122944 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
439 I, [2016-09-02T16:54:15.122978 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
440 I, [2016-09-02T16:54:15.123010 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
441 I, [2016-09-02T16:54:15.123068 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
442 I, [2016-09-02T16:54:15.123102 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass
443 I, [2016-09-02T16:54:15.123134 #13978]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass



require "logger"
require "celluloid/current"

f = File.open("logs/celluloid.log", "w+")
Celluloid.logger = ::Logger.new(f)

class ErrorHandler
  include
Celluloid
  include
Celluloid::Internals::Logger


  trap_exit
:actor_died


 
def actor_died(actor, reason)
    info
"actor: #{actor.inspect} reason: #{reason.class}"
 
end
end


class QueueFetch
  include
Celluloid
  include
Celluloid::Internals::Logger


 
def fetch(queue_url)
    info
"fetched #{queue_url}"
 
end
end

pool
= QueueFetch.pool(size: 200, args: [])
err_handler
= ErrorHandler.new
pool
.actors.each{|a| a.link err_handler }


1_000.times { |n| pool.async.fetch(n) }

//de

unread,
Sep 2, 2016, 8:38:26 PM9/2/16
to cellulo...@googlegroups.com, Tim Linquist
It appears you need to add a sleep at the end of your program otherwise all of the asynchronous tasks will launch but then the main thread will die before the asynchronous tasks complete.

For server applications we have an infinite sleep usually otherwise do some sort of loop at the end which checks for completion.

This was just my knee-jerk response after looking at the code.

Tim Linquist

unread,
Sep 2, 2016, 10:02:13 PM9/2/16
to Celluloid, tim.li...@gmail.com
Uh vey! That's exactly right. All threads finish now.

Ok now next question, after the sleep all threads still log 
I, [2016-09-02T18:59:35.202066 #15589]  INFO -- : actor: #<::Celluloid::Proxy::Cell(QueueFetch) dead> reason: NilClass


It says in the docs that the pool will shutdown actors properly when its garbage collected. Is that outdated?


https://github.com/celluloid/celluloid/wiki/Pools#shutdown


Thanks for your help! I should remember anytime I think it's the lib it's almost always me

//de

unread,
Sep 2, 2016, 10:22:56 PM9/2/16
to cellulo...@googlegroups.com, Tim Linquist, tim.li...@gmail.com
Why are you directly interacting with actors in the pool, using .link on a non-actor error handler object?
Reply all
Reply to author
Forward
0 new messages