Random hang (requiring SIGKILL) in script talking to postgresql using rails application

Hello

We have a ruby-script for running system tests which talks to a
database (to e.g. log each testrun) through a rails application.
Sometimes this script freezes completely, only responding to SIGKILL.
Have anyone else noticed this or have any idea where to start
debugging (I’ve inherited the code and unfortunately don’t know too
much about ruby on rails yet…) I have a hunch that the problem is
related to the database access as the problem was reduced after
deactivating a few tests which talk to the database a lot.

The script runs on linux (RHEL4) using rails version 2.3.4 and
postgresql version 8.3.7. The database handler is pg, version 0.8.0

Mathias Lidal