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 1jBEFD-0007ap-CH for pgsql-general@arkaria.postgresql.org; Mon, 09 Mar 2020 08:58:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jBEFB-00079Z-VV for pgsql-general@arkaria.postgresql.org; Mon, 09 Mar 2020 08:58:37 +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 1jBEFB-00079S-JS for pgsql-general@lists.postgresql.org; Mon, 09 Mar 2020 08:58:37 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jBEF8-0001Gh-SI for pgsql-general@postgresql.org; Mon, 09 Mar 2020 08:58:37 +0000 Received: by mail-lj1-x243.google.com with SMTP id w1so9039949ljh.5 for ; Mon, 09 Mar 2020 01:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=NVG+vsjgWTnByVBu6Scue+8M2AgqaoAlXhJFK8bl5lM=; b=TcHe+s3FWgK8CQOHaZ7kaydSrDCC86MbNkhaKWPVfCW26cfMo7xyWDQ2gatgW3OVO0 2Vbkg+V4ClYJXeSZdUFNuB3pTzLG6POQw9t5xV48VSxhawHzwI7+oGkRC1GmqccZQYXZ Lc0Qie8RGO5VUQjZBoO0paNR8S83RP6+PCYqivyr9FVtnilIaLGSi+jGRxbo8UTTXcd8 iP0pr8l9smce7n7TrxL4+1DMlnz6oUUKlsbd/qv6hfjsXUwv5h6OSL4FSMtuez1gs/sW YupD4g1Ww2eoIyqKZJ+mlLIQOqPOaYUH4u6ENOjBj0OgrAuvEp7KFs3i71jLJI1kLkrO 6pbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NVG+vsjgWTnByVBu6Scue+8M2AgqaoAlXhJFK8bl5lM=; b=txPjD+Iyuzd4dkZGhTamAqkY7/+FPEQvMdg1InSUl7pUGZCl//wE1gO8kbEYl24/l1 1wWFs441MeYkd40Xjc/GXFhU8xFy9YysAx3Z69BWCfyH7zTKqxTbUjlmueYrbDXfP3s0 AbyVwadFY0sQK4dX9eKBJD2Nar36gJ1Rr9vy89ypjINpTuLtL63eD3hY8X5yX0EDwu5B yK+q+A0w0A1cqoSWFyna8qB5gNlINAmC31yJzhvPPvVWODNX1DbmZG/xUp2CIGJII+17 yLvvyz+4Sri9GTALIplfUTNvDbc6hr0llJhheFLqhCd44GkScIslZDIfxAuzR+TopgtW cjnQ== X-Gm-Message-State: ANhLgQ15xTHVp9yKRu3j1LjiqQgKp9gkc6aWFz8lu0UFPNRGgYKpap7J m08kNbSaPlvUUtGbgvjaEhA= X-Google-Smtp-Source: ADFU+vt9YmR/ttm0mNq2inw2PYQgTyqDz2nBRYZZ+UtZFSIpDc2zyqyZdDChp9C46IbmNJmXhosTGg== X-Received: by 2002:a2e:8814:: with SMTP id x20mr8833176ljh.231.1583744313109; Mon, 09 Mar 2020 01:58:33 -0700 (PDT) Received: from nol (82-64-124-11.subs.proxad.net. [82.64.124.11]) by smtp.gmail.com with ESMTPSA id y11sm313222ljn.83.2020.03.09.01.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2020 01:58:32 -0700 (PDT) Date: Mon, 9 Mar 2020 09:58:29 +0100 From: Julien Rouhaud To: Josef Machytka Cc: Postgres General Subject: Re: strange locks on PG 11 with Golang programs Message-ID: <20200309085829.GA34056@nol> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Mar 09, 2020 at 09:51:21AM +0100, 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. > > 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? The query displayed is just the query currently executing, but if the connection is in a transaction the problematic lock could have been acquired by any previously executed query. Did you check in pg_stat_activity if the connection is in a transaction (e.g. query_start != xact_start)?