Multi-threaded database interaction

Hello,

I recently wrote a Rails app that launches 7 threads that each need to
do ActiveRecord::Base.finds on a PostgreSQL database. I figured that
since no database information is being changed on calls to find, these
calls would not require mutual exclusion. However, if I don’t use
mutual exclusion, I get all sorts of weird errors not long after the
threads are spawned. It works just fine if I use mutual exclusion.
Anyone know why this is? Thanks!

Matt W. schrieb:

you wouldn’t happen to be sharing variables among threads?

I recently had that problem; I had mistakenly used instance vars in a
threaded server. Then each new thread would change the instance vars
and the old thread would go crazy with the new values.

never used the mutual exclusion though, the pick-axe discussion scared
me away

/ak

On Jul 6, 3:42 pm, Andy K. [email protected] wrote:

you wouldn’t happen to be sharing variables among threads?

I recently had that problem; I had mistakenly used instance vars in a
threaded server. Then each new thread would change the instance vars
and the old thread would go crazy with the new values.

never used the mutual exclusion though, the pick-axe discussion scared
me away

/ak

Nope, I was pretty careful about launching each thread with its own
instance variables.