Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJzBB-0002nI-1l for pgsql-general@arkaria.postgresql.org; Tue, 06 Nov 2018 11:05:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gJzB7-0000xd-O2 for pgsql-general@arkaria.postgresql.org; Tue, 06 Nov 2018 11:05:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gJzB7-0000xW-Fm for pgsql-general@lists.postgresql.org; Tue, 06 Nov 2018 11:05:49 +0000 Received: from mx2a.mailbox.org ([2001:67c:2050:104:0:2:25:2] helo=mx2.mailbox.org) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gJzB0-0003Kt-FS for pgsql-general@lists.postgresql.org; Tue, 06 Nov 2018 11:05:48 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 6C836A111E; Tue, 6 Nov 2018 12:05:40 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id CCH_P30hyUDm; Tue, 6 Nov 2018 12:05:37 +0100 (CET) Message-ID: Subject: Re: CREATE OR REPLACE FUNCTION statement just sitting there From: Laurenz Albe To: Ron , pgsql-general@lists.postgresql.org Date: Tue, 06 Nov 2018 12:05:36 +0100 In-Reply-To: <2394ea86-6a5f-ddce-8929-a37376192eaf@gmail.com> References: <924318ab-f639-8116-e3a4-af4890dd5e5d@gmail.com> <2394ea86-6a5f-ddce-8929-a37376192eaf@gmail.com> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ron wrote: > > > However, one or more of our big (and schema-identical) prod databases (which are each on a different server) > > > it is finicky and tends to just "sit" at a random one of the CREATE OR REPLACE FUNCTION statements. > > > > > > The "list all blocking queries" I run doesn't show that anything is blocking it (though it blocks > > > everything else), and neither top(1) nor iotop(1) show any activity. > > > > > > If it matters, this script is fed to the databases via the JDBC driver, and it works fine when I run it via psql. > > > (I'd gladly run the scripts manually, but these are child databases, and a parent db must be updated > > > at the same time by a canned application.) > > > > > > Where in Postgres can I look to see why it's just sitting there? > > > > select * from pg_stat_activity; > > might shed some light? > > That (plus pg_locks) is the heart of the "list all blocking queries" statement I copied > from https://wiki.postgresql.org/wiki/Lock_Monitoring. If there is nothing with "granted" set to FALSE in "pg_locks", you are not blocked by a database lock. What is the "state" of the hanging database session in "pg_stat_activity"? If it is "idle" or "idle in transaction", then the lock must be in your Java process. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com