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.89) (envelope-from ) id 1ircHC-0008En-Pf for pgsql-general@arkaria.postgresql.org; Wed, 15 Jan 2020 06:35: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 1ircGC-0000em-G6 for pgsql-general@arkaria.postgresql.org; Wed, 15 Jan 2020 06:34:36 +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 1ircGC-0000ee-1a for pgsql-general@lists.postgresql.org; Wed, 15 Jan 2020 06:34:36 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ircG3-0005wG-HQ for pgsql-general@postgresql.org; Wed, 15 Jan 2020 06:34:35 +0000 Received: by mail-wm1-x342.google.com with SMTP id b19so16495402wmj.4 for ; Tue, 14 Jan 2020 22:34:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=51RDyYamNMY6TLD81aPfRPW79WhMwvc0ScA5d+CTsDI=; b=kWTN/uRegGd/haMCtGMTxcePAsrzAJbSi8J/d0UIpHSq9G4brXkejOWKixBq9iUj0O TDrGSQXdzhycJv1OZRnH7vQBKbdS4iG+jjrtvhOTSxQGLZhOCD1IUiXG26cvuMncivkG DU5UmK2hOvfodHw5Q5ApXD5rMio+Oq2rJ3XJaHgnLSHDfpGp2iVgVO6s2SvxmlRnp30u HVmlXimPm87dum33drL9PT7opAzDvMx0aFRITja3v6nB6r4QIFHuTJNCJ7jqoqzJyrao rxFW8ZbJ4L0R03R2wOPCojG7wUsJZPInzhrX3SlKk4eYgvDeNU3cZR6xZ82vpD7TNAie g13A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=51RDyYamNMY6TLD81aPfRPW79WhMwvc0ScA5d+CTsDI=; b=ZwI0+cFxVCvD076QZhxevyHWSXgRIlqQm08iAl7CXnYUBeP6PGhS8g7GqSAs5nxRB0 6HvI+3cfpGJeOdvIQlhA0cl+Vf8awsZKel5BIuxj+QmebKnnMNT5Wth35GvkN/McKoQE QuO1wNiEy0fT6uaZzkCaL30LiCEb1a4mwiRnWwAWGn2mxPdpjzSoJLoZvg9oFEdF+XAq vbj49d05qE7GetsAtR5GxiUIyJfAj/awdpX2GRg5TPG7z0hExeScUNX/efU0D3X+qEMY SWJFZW9+4uPmV8YWxNScLX6eDSahp/5YYDDmbFbN+a82UVxbYB1gdCkhUHXzEPratjlE mBjw== X-Gm-Message-State: APjAAAXxzIdw2QZ+eR0uEKDQZmxjuVwTDh2bBp/lPxAnZk9D7hK7n9Zi RvsW4Nsd423g6dp6Ry2QMryHRQ== X-Google-Smtp-Source: APXvYqwsgp09jvyV9r+8PY2a/yCQ4h5OVadhjUEhwRvxLS7oIpcyH/5cDunFOJPWd/h8SomvWqeEpg== X-Received: by 2002:a1c:6588:: with SMTP id z130mr32139712wmb.0.1579070066270; Tue, 14 Jan 2020 22:34:26 -0800 (PST) Received: from localhost.localdomain (pd95690bc.dip0.t-ipconnect.de. [217.86.144.188]) by smtp.gmail.com with ESMTPSA id v14sm22885635wrm.28.2020.01.14.22.34.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 22:34:25 -0800 (PST) Message-ID: Subject: Re: Lock leaking out of Transaction? From: Laurenz Albe To: James Sewell , pgsql-general Date: Wed, 15 Jan 2020 07:34:22 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, 2020-01-15 at 10:42 +1100, James Sewell wrote: > I am trying to chase down a locking issue - it looks like a materialized view refresh is being > held up by a relation lock which is held by an out of transaction session. My understanding was that > this was not possible (see SQL output below). > > The locking session is making progress (I can see query_start advancing), which makes it even more confusing. > > Any advice? > > # select * from pg_locks l join pg_stat_activity a on l.pid = a.pid where relation = 1438729::regclass; > -[ RECORD 1 ]------+--------------------------------------------------------------------------------- > locktype | relation > database | 16428 > relation | 1438729 > mode | ShareUpdateExclusiveLock > granted | f > fastpath | f > pid | 88955 > wait_event_type | Lock > wait_event | relation > state | active > query | autovacuum: VACUUM supply_nodes (to prevent wraparound) > backend_type | autovacuum worker > -[ RECORD 2 ]------+--------------------------------------------------------------------------------- > locktype | relation > database | 16428 > relation | 1438729 > mode | ExclusiveLock > granted | f > pid | 6839 > wait_event_type | Lock > wait_event | relation > state | active > query | REFRESH MATERIALIZED VIEW CONCURRENTLY supply_nodes ; > backend_type | client backend > -[ RECORD 3 ]------+--------------------------------------------------------------------------------- > locktype | relation > database | 16428 > relation | 1438729 > mode | ExclusiveLock > granted | t > pid | 65447 > application_name | PostgreSQL JDBC Driver > wait_event_type | Client > wait_event | ClientRead > state | idle > query | COMMIT > backend_type | client backend I cannot explain that either; could it be shared memory corruption? What I would try is SELECT pg_terminate_backend(65447); and see if the session and its lock go away. If that does not do the trick, I would restart PostgreSQL, which should get rid of any possible memory corruption. Then perhaps the anti-wraparoung autovacuum can succeed. This autovacuum would also block you, but you should let it finish, since it is an important system task. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com