Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74655
| References | <CACwCsY7BWeV14+=OHbgYyfwV8qGkTv_nRC4e4+Ahxv3+RP+tng@mail.gmail.com> <CAPTjJmpi8d28ahbba0LNQU8rY4r0EvwUmDS2zRMVsUn0tubtuQ@mail.gmail.com> |
|---|---|
| Date | 2014-07-17 13:55 -0400 |
| Subject | Re: Blocked thread |
| From | Larry Martell <larry.martell@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11937.1405619727.18130.python-list@python.org> (permalink) |
On Thu, Jul 17, 2014 at 1:32 PM, Chris Angelico <rosuav@gmail.com> wrote: > On Fri, Jul 18, 2014 at 2:26 AM, Larry Martell <larry.martell@gmail.com> wrote: >> I have a python cx_Oracle script that does a delete from a table. >> Usually this takes well under 1 second. But sometimes it takes 1 to 2 >> minutes. I wanted to monitor that delete and if it's taking too long I >> want to see what is blocking it. I run the delete sql in a thread... > > I don't know Oracle specifically, but if it's anything like > PostgreSQL, you'll probably do better with a completely separate > connection to the server, which might need to be a separate process. > In PostgreSQL, I can query currently-active transactions thus: > > rosuav=> select state,query from pg_stat_activity; > state | query > ---------------------+------------------------------------------- > idle in transaction | select * from pg_stat_activity; > active | select state,query from pg_stat_activity; > active | drop table test; > (3 rows) > > (Better than that: Add "where pid=..." to that, using the backend PID > provided by the thread you're monitoring, by "SELECT > pg_backend_pid()". But that's even more PostgreSQL-specific.) > > With info like that, you can see what's happening, and whether it's > stalled out or in a query or whatever. You should also be able to get > some timestamps (Postgres can do that, I would be highly surprised if > Oracle can't), such as when the transaction started, so you can see > how long it's been stalled. > > Thing is, this requires a quite separate connection, which means > you're monitoring the far end rather than the local thread. I suspect > this will give you better results; Oracle's bound to have facilities > for doing this, whereas your local thread may or may not be usefully > monitorable. I can have as many connections to the db server as I want, that's not the issue. The issue is that my main thread seems to be blocked in the join(), so I guess I'm going to need a separate script. I was trying to avoid that.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Blocked thread Larry Martell <larry.martell@gmail.com> - 2014-07-17 13:55 -0400
csiph-web