Forum OpenACS Development: Re: db_transaction hanging a thread how to detect, how to kill...

PG will detect deadlocks, and fail the operation if it finds one. See the DEADLOCK_TIMEOUT option at http://www.au.postgresql.org/docs/7.2/static/runtime-config.html

This is pure unfounded speculation, but I'd start with the db_ API and it's handle allocation...