How to find what Java program has a transaction open? - Mailing list pgsql-jdbc

From Paul Tomblin
Subject How to find what Java program has a transaction open?
Date
Msg-id 47BB838D.5070903@gmail.com
Whole thread Raw
List pgsql-jdbc
I got the following query from a comment on the PostgreSQL site:

select pg_stat_activity.datname,pg_class.relname,pg_locks.transaction,
pg_locks.mode,pg_locks.granted,pg_stat_activity.usename,substr(pg_stat_activity.current_query,1,30),
pg_stat_activity.query_start, age(now(),pg_stat_activity.query_start) as
"age", pg_stat_activity.procpid from pg_stat_activity,pg_locks left outer join
pg_class on (pg_locks.relation = pg_class.oid)  where
pg_locks.pid=pg_stat_activity.procpid and pg_class.relname not like 'pg_%'
order by query_start;

and it's great, in that it shows me what Postgres PID is holding the lock, and
on what table.  But what I don't know is how to figure out what Java program
it is that's got the lock.  If I do a "ps auwwx | grep [pid]", the socket
number will be part of the command line for that process, and then I can use
"lsof -i :[socketnumber]" which shows me two tasks that have that socket open,
the PostgreSQL task and the Java task, and then I can use "ps auwwx | grep
[pid]" to find the arguments to the Java task, including the main class.

Is there a more direct way?

--
Paul Tomblin <ptomblin@xcski.com> http://blog.xcski.com/
Compared to system administration, being cursed forever is a step up.
               -- Paul Tomko

pgsql-jdbc by date:

Previous
From: Michael Paesold
Date:
Subject: Re: Implementing setQueryTimeout() - round 2
Next
From: Gustav Trede
Date:
Subject: Re: extra rowcopy in ResultSet allways needed ?.