Re: EventMachine.defer and ActiveRecord connection pool?



Chuck Remes wrote:
I have a guess. I guess that your CONFIG['resources_manager.period']
is set to 0 or quite close to it. If so, the PeriodicTimer is probably
firing on every "crank" of the EM reactor which is deferring more and
more of your singleton blocks. There isn't any time left over to clean
up connections to the ActiveRecord connection pool and you are running
out.
Nop, it's 1 second for testing. It happens even if you set it to 1
minute. Loads of time to clean up and still...

BTW, EM#defer uses a threadpool (size of 20). It enqueues each #defer
request to a Queue (thread safe). As each thread in the pool completes
its task it pops the next one off the queue.

If you flood the queue (which I suspect) then the newest tasks are
going to starve while waiting for the previous ones to complete. As
each task completes, try outputting the number of tasks in your
@@running hash and see if it is a large number.
The whole purpose of @@running hash is to ensure that same task won't be
running in parallel. I don't need two resource managers messing up
values with database, so it skips that block completely if same task is
still running.
--
Posted via http://www.ruby-forum.com/.

.



Relevant Pages

  • Re: filewatcher question
    ... I guess I can get the file watcher change event to just queue up the file ... Furthermore the file watcher changed event will do a quick look up if the ... I will also have to look up thread safe GUI as well ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Thread safe vector class
    ... > between worker threads and the main thread. ... producer/consumer queue. ... If that one doesn't fit your needs, Google for "thread safe producer ...
    (microsoft.public.vc.language)
  • Re: Thread safe queue in C
    ... within linux with C and i need a thread safe queue.How can i obtain a ... Anyway, creating a queue with POSIX Threads is rather trivial, I don't see why you can't quickly create one: ... typedef struct queue_s queue; ... queue* const _this, ...
    (comp.programming.threads)
  • Re: Get multiprocessing.Queue to do priorities
    ... The Queue module, apparently, is thread safe, but *not* process safe. ... If you try to use an ordinary Queue, it appears inaccessible to the worker process. ...
    (comp.lang.python)
  • Re: STL Queue
    ... > In the STL documentation, it says that a queue is not thread safe. ... > Thread A will "push" stuff onto a queue. ...
    (microsoft.public.win32.programmer.ui)