Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

[JDBC] How to find what Java program has a transaction open?

From: Paul Tomblin <ptomblin(at)gmail.com>
Date: Tue Feb 19 2008 - 20:34:05 EST


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(at)xcski.com> 
http://blog.xcski.com/
Compared to system administration, being cursed forever is a step up.
               -- Paul Tomko

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match
Received on Tue Feb 19 20:37:31 2008

This archive was generated by hypermail 2.1.8 : Wed Jun 18 2008 - 23:45:01 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library