Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jBEJE-000854-Q2 for pgsql-general@arkaria.postgresql.org; Mon, 09 Mar 2020 09:02:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jBEJD-0002Mf-HL for pgsql-general@arkaria.postgresql.org; Mon, 09 Mar 2020 09:02:47 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1jBEJD-0002MY-7c for pgsql-general@lists.postgresql.org; Mon, 09 Mar 2020 09:02:47 +0000 Received: from hermes.gatewaynet.com ([193.92.121.98]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jBEJB-0001Ir-6f for pgsql-general@lists.postgresql.org; Mon, 09 Mar 2020 09:02:46 +0000 Received: from smadev.internal.net (pc131.internal.net [10.9.200.131]) by hermes.gatewaynet.com (8.15.2/8.15.2/Debian-8) with ESMTPS id 02992bD2022101 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 9 Mar 2020 11:02:42 +0200 Received: from smadev.internal.net (smadev [10.9.200.131]) by smadev.internal.net (8.15.2/8.15.2) with ESMTP id 02992b7x048632 for ; Mon, 9 Mar 2020 11:02:37 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) Subject: Re: strange locks on PG 11 with Golang programs To: pgsql-general@lists.postgresql.org References: From: Achilleas Mantzios Message-ID: Date: Mon, 9 Mar 2020 11:02:37 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.3.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------1E1A74A2058445E6F7A12AB7" Content-Language: en-US X-Virus-Scanned: clamav-milter 0.101.4 at hermes X-Virus-Status: Clean X-Spam-Status: No, score=-28.0 required=5.0 tests=ALL_TRUSTED,DYN_HAM_COORD, DYN_HAM_IT,DYN_HAM_NAUTICAL,HTML_MESSAGE autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on hermes.gatewaynet.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------1E1A74A2058445E6F7A12AB7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 9/3/20 10:51 π.μ., Josef Machytka wrote: > > We are lately experiencing very strange locks on PostgreSQL 11.7 when we process ETL tasks using our programs in Go 1.13.8 using standard libraries sql and pq. > > ETL task has to rename tables but PostgreSQL shows that this simple operation waits for Lock on relation and select from PG wiki (https://wiki.postgresql.org/wiki/Lock_Monitoring) which should show > blocking process shows that command "alter table .... rename to ...." is blocked by process "COPY .... to stdout" but from completely different table. > Fully review your programs for connection / xaction leaks. Do you use a connection pool? Make sure in the code that you close any connections that you open, even after exceptions , try to identify idle in transaction connections from pg_stat_activity , remember to either commit or rollback non-autocommit connections (just for the sake of clarity). > And from time to time even selects from some tables seem to by blocked by copy commands running on other tables. This is shown by the same select from PG wiki for blocking queries. > > All this stuff runs from golang programs. So maybe problem is not on PostgreSQL but in golang libraries? > > Thank you for any suggestions > > Josef Machytka > > Berlin > -- Achilleas Mantzios IT DEV Lead IT DEPT Dynacom Tankers Mgmt --------------1E1A74A2058445E6F7A12AB7 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 9/3/20 10:51 π.μ., Josef Machytka wrote:

We are lately experiencing very strange locks on PostgreSQL 11.7 when we process ETL tasks using our programs in Go 1.13.8 using standard libraries sql and pq.

ETL task has to rename tables but PostgreSQL shows that this simple operation waits for Lock on relation and select from PG wiki (https://wiki.postgresql.org/wiki/Lock_Monitoring) which should show blocking process shows that command "alter table .... rename to ...." is blocked by process "COPY .... to stdout" but from completely different table.


Fully review your programs for connection / xaction leaks. Do you use a connection pool? Make sure in the code that you close any connections that you open, even after exceptions , try to identify idle in transaction connections from pg_stat_activity , remember to either commit or rollback non-autocommit connections (just for the sake of clarity).

And from time to time even selects from some tables seem to by blocked by copy commands running on other tables. This is shown by the same select from PG wiki for blocking queries.

All this stuff runs from golang programs. So maybe problem is not on PostgreSQL but in golang libraries?

Thank you for any suggestions

Josef Machytka

Berlin



-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt
--------------1E1A74A2058445E6F7A12AB7--