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 1jBEqP-00033k-Pm for pgsql-general@arkaria.postgresql.org; Mon, 09 Mar 2020 09:37:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jBEqO-0008Vz-E3 for pgsql-general@arkaria.postgresql.org; Mon, 09 Mar 2020 09:37:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jBEqN-0008UI-Qu for pgsql-general@lists.postgresql.org; Mon, 09 Mar 2020 09:37:04 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jBEqK-0008Kn-Qi for pgsql-general@postgresql.org; Mon, 09 Mar 2020 09:37:02 +0000 Received: by mail-lf1-x132.google.com with SMTP id j17so2549430lfe.7 for ; Mon, 09 Mar 2020 02:37:00 -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=9YAd6BLsQRbLUFbk0opWn3n3PpeC+6llj8KikeIOEk8=; b=qJ+65RBbmSo+9owYrOGR6sQHS6xXPfzUIuGSMaxCVE82TJmZWDbvH+mAGQ7jVhPCoy TWbJnsBJVai34n0OYnlRlWkg5bgdL+9ufU/CI3XdLqozHImODpGZdRqwIQ+NKMeK5uF7 whROFrQpIKGgY0UWrAhAxhb6aWxV5cr9JPwAr9lGtt29JO2qv39mR90cM8iNUJdFXAe0 kzKpfr5qwpcDdVfHJ621OJraj/LLW2J16J3b3A3i/UyTomnbNI4s//dmqnmtyotJUgE+ Ccb2ajH9f9vtvZmf/iYdNurmY130zFonKjwI1VJYZcHG2Jw75QNK5ueXdHc9dYhADSY2 pYWA== 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=9YAd6BLsQRbLUFbk0opWn3n3PpeC+6llj8KikeIOEk8=; b=IEw+HYhL9R0GWaIHfwtb2FZTgnnVhiOtNornEq5hHuRsywkXzQL7xIrYAouNpC52Xy kDQa2TB5PjWO+4P+enY47R0CcxYKgwskAeqYV5WITP/M3MQR/oChz4NCD1VJc0ll8433 WuDXYoQo1tj1V5idvS4z4S8LVt+Hz+Wmql2kLJB1XN2LKTKWuNJ6uPkdGR0QuFKQnZVQ DSJPKWPXeKv4UqLsjAKsu4UqVoEIbHP7v33fHmybbJ7+RY8z3j/LuYUJMoyQSg0aM9Yr ecYJLW5j6DLTD4VHvOvzu+DHRlAsX1oTw8MmQeoGLbYrIFelB/33lU9k2LWzYjxClgbc u64w== X-Gm-Message-State: ANhLgQ1VX1zf9OZhbOu6zPjB1e09xNWUXVtGsBhtTuesaP6fZoceiskO eN4DRM+Kd5+Xl8fbazNPkVc= X-Google-Smtp-Source: ADFU+vvDHyvs9z6g7lIL9Tx6vYBD84zXGtGLnFZY2BjsPDFIY6pFK3Gdlzr5hr9+ANoVb1d0rSA5Kw== X-Received: by 2002:a19:ac42:: with SMTP id r2mr4735844lfc.38.1583746618954; Mon, 09 Mar 2020 02:36:58 -0700 (PDT) Received: from nol (82-64-124-11.subs.proxad.net. [82.64.124.11]) by smtp.gmail.com with ESMTPSA id s11sm15247621ljc.63.2020.03.09.02.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2020 02:36:58 -0700 (PDT) Date: Mon, 9 Mar 2020 10:36:55 +0100 From: Julien Rouhaud To: Josef Machytka Cc: Postgres General Subject: Re: strange locks on PG 11 with Golang programs Message-ID: <20200309093655.GA39356@nol> References: <20200309085829.GA34056@nol> 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 10:21:23AM +0100, Josef Machytka wrote: > On Mon, 9 Mar 2020 at 09:58, Julien Rouhaud wrote: > > > 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)? > > Oh, I see. Thank you. I modified query from wiki and it shows that blocking > session actually runs for ~12 hours already. Only last COPY command started > recently. So maybe golang library did not close session properly and reused > it in another completely different task? Although I defer db.Close() > everywhere... I don't know anything about golang libraries, but this sounds like a problem of a simulated non-autocommit mode in the driver/lib. You should look at transaction handling with the lib you're using.