Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'scripts': 0.03; 'causing': 0.04; 'detect': 0.07; '(chicago,': 0.09; 'second.': 0.09; 'cc:addr :python-list': 0.11; 'blocking': 0.16; 'competent': 0.16; 'finds': 0.16; "he'll": 0.16; 'it."': 0.16; 'jersey,': 0.16; 'seconds,': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thu,': 0.19; 'minutes.': 0.22; 'cc:addr:python.org': 0.22; 'him.': 0.24; 'fine': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'query': 0.26; 'tables': 0.26; 'second': 0.26; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'locations': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'info.': 0.31; 'larry': 0.31; 'operations.': 0.31; 'this.': 0.32; 'figure': 0.32; 'run': 0.32; 'running': 0.33; 'fri,': 0.33; 'table': 0.34; 'problem': 0.35; 'knows': 0.35; "who's": 0.35; 'but': 0.35; 'received:google.com': 0.35; "he's": 0.36; 'done': 0.36; 'next': 0.36; 'server': 0.38; 'issue': 0.38; 'pm,': 0.38; 'that,': 0.38; 'how': 0.40; 'monitoring': 0.61; 'new': 0.61; 'more': 0.64; 'different': 0.65; 'taking': 0.65; 'situation': 0.65; 'to:addr:gmail.com': 0.65; 'minutes': 0.67; 'london,': 0.72; 'jul': 0.74; '4:00': 0.84; 'dba': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=KTcJ5awpdcWKhVyVhqUjJeiNHL3DrY7fTkWTOURA9C0=; b=W/WuA/6aRlun1GbI8ap/FqQ5hNDEi6VbXAcriQDujcUIeFL1IqwWIrJ/41GBhyiGrt yQ8Xz5S4/dVtmiHuzUfiXM/cViZWplXljakoPAvQXnEQrPuUQY2660feh36q7Tn5nvsM TXR46zkiDPvuho5um/Xhivs222vLOqT4QUZ3jlyw8JY9P+6CuXMueV1bPthJZz/FeLH8 tm92JQi/Boeu2vrfERqwHCCvq7lwygzewQXrkqD0umroxsX8fWGkhBxnRnQWnic5Yh0i RXSF/CYBdYp4mwkxpzuYe16HURIIx0gVGvfeC2pc32rG8BG3I+3TTZvy8MB1vdy+qN3S vqWQ== MIME-Version: 1.0 X-Received: by 10.194.222.230 with SMTP id qp6mr47911785wjc.23.1405620800341; Thu, 17 Jul 2014 11:13:20 -0700 (PDT) In-Reply-To: References: Date: Thu, 17 Jul 2014 14:13:20 -0400 Subject: Re: Blocked thread From: Larry Martell To: Chris Angelico Content-Type: text/plain; charset=UTF-8 Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405620808 news.xs4all.nl 2924 [2001:888:2000:d::a6]:41889 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74662 On Thu, Jul 17, 2014 at 2:04 PM, Chris Angelico wrote: > On Fri, Jul 18, 2014 at 4:00 AM, Larry Martell wrote: >> I did ask my DBA - he said "Blocking is a normal part of database >> operations. It's only a problem when it's a deadlock, in which case >> the server will detect that, kill one of the processes and log it." >> >> My situation is not a deadlock - there's just multiple scripts hitting >> the same tables at the same time. When one gets done the next one >> proceeds. I just want to find out what are the other processes causing >> this. > > Then you definitely want server-side info. The DB server's the one who > knows who's waiting on whom. See if your DBA can help you with the > specifics; this will be bread-and-butter monitoring work for him. > Automating it might require some tweaking, but if he's at all > competent at his job, he'll know how to figure out (if manually) > what's blocking an important query. I know what SQL to run to see who is blocking whom. The issue is that the scripts that are hitting this table run every 5 minutes 24/7 from 5 different locations (Chicago, New Jersey, London, Tokyo, and Sydney). 99% of the time it's fine and the query takes under 1 second. But every once it a while it takes 2 minutes. It will be hard to detect that manually. What I was trying to do in my threaded code was detect when it was taking more than 5 seconds, and then start monitoring it. I think I just need a second script that is always running and when it finds blocking, log it to a file. I was trying to avoid that and deal with it from within.