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 1eu1UP-0000u0-Gh for pgsql-general@arkaria.postgresql.org; Thu, 08 Mar 2018 19:46:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eu1UO-0007Qe-FY for pgsql-general@arkaria.postgresql.org; Thu, 08 Mar 2018 19:46:08 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eu1UM-00077e-P9 for pgsql-general@lists.postgresql.org; Thu, 08 Mar 2018 19:46:07 +0000 Received: from mail-it0-x22f.google.com ([2607:f8b0:4001:c0b::22f]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eu1UJ-0006Fz-1O for pgsql-general@postgresql.org; Thu, 08 Mar 2018 19:46:05 +0000 Received: by mail-it0-x22f.google.com with SMTP id u5so9374016itc.1 for ; Thu, 08 Mar 2018 11:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KMKz2Gk+r3x1/9JF91sLQ9vcW8WggFbHPBuFd7IvyhY=; b=cUWkPpes08Sr5FbZaKm3ABdR70bwCiyMKvPxhpNpEH5OCg+tm3L+SjuifXJxrcuUZx meeZYVkSSlJo8psn6zZq2qANVqNEeV5yzVQz0D+6sJMbcWQdwGosCDXxO8fGdEIE8gn8 yMKzVDt7Nk0Ga7EqwQ9tnWJfgOoZXQsz8rHl7LxdALDaN9yBdlv84DkaLSEJVnKyoQC1 RMjV24Q7uDqkC9yyxZ/4OQ5eeLAXYmFuZEB4hUSYbpS0FMj7UBuUdAC2ATZMXouGl2AK 8OsaDY8gPfI94w0hMXBZIsnpHIXGUP5EhAjKJteWUJXWvF31ehclm0UldLJjCgXXkuhf Y0BQ== 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:user-agent; bh=KMKz2Gk+r3x1/9JF91sLQ9vcW8WggFbHPBuFd7IvyhY=; b=NiI6PHk606X6PUevbww7DL5mShiMoh/12BDKmLC37bdEtJEJkARniLSyUThnNvKdeE 4YcI2CZ+xPYo8noEG0KIryN2EYSAzdtGOm9+2CGAQTXIo4gNRzfOOA02CTZcofEcYBki ECEIbUqLgu5z9174CY54sampk6RkjSklResunOBgmRoROppWOZyn2KDddOCKZ4IhTogm I8xEr03k7ad1X2uApRCbUZJg56f0qPocPEWcrGgIiWjJtFV9UvhVzo/ICL2uY7BKUm8r r2TxRyDbibxic1K63ahp+FQhVgW3EhDRCFa5iNb7hea/4c4su2fPK/x1VGheDUFr7VH3 CNPg== X-Gm-Message-State: AElRT7HbukF7rgjU3ubJlWMFGc/aBxrNwp5vcN7iLit4uua83gxUS/f2 2aEQeCq7eMxeVj6IBscjCIhyLqTPfkk= X-Google-Smtp-Source: AG47ELuMT6u2L66ofrHWdGPKZ4YtH5xs6meVH+xaTO+AfBXuF+qcPKOQMWn9r4fEOCmd/kw7zikdIA== X-Received: by 10.36.170.6 with SMTP id b6mr29713980itf.148.1520538361774; Thu, 08 Mar 2018 11:46:01 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id f191sm8915587ite.4.2018.03.08.11.46.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 11:46:01 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id 0B706801040; Thu, 8 Mar 2018 13:45:59 -0600 (CST) Date: Thu, 8 Mar 2018 13:45:59 -0600 From: Justin Pryzby To: Tom Lane Cc: pgsql-general@postgresql.org Subject: Re: circular wait not triggering deadlock ? Message-ID: <20180308194559.GK24441@telsasoft.com> References: <20180308182629.GJ24441@telsasoft.com> <21765.1520535426@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21765.1520535426@sss.pgh.pa.us> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Mar 08, 2018 at 01:57:06PM -0500, Tom Lane wrote: > Justin Pryzby writes: > > Running pg10.2, I have a handful of maintenance jobs run in the middle of the > > night, which appear to have gotten stuck waiting on each other.. > > > ts=# SELECT granted, pid, mode, virtualtransaction, virtualxid FROM pg_locks WHERE virtualxid='22/4317099' ORDER BY 1,2,3; > > granted | pid | mode | virtualtransaction | virtualxid > > ---------+-------+---------------+--------------------+------------ > > f | 20488 | ShareLock | 19/28401734 | 22/4317099 > > t | 6471 | ExclusiveLock | 22/4317099 | 22/4317099 > > PID 20488 is evidently waiting for PID 6471 to finish its transaction. > What's that one doing? Um, I thought I had kept track of all two pids but looks not.. query | SELECT pg_export_snapshot(); So that explains that. I already killed one proc, but.. ts=# SELECT granted, relation::regclass, pid, mode, virtualtransaction, virtualxid FROM pg_locks WHERE pid=17248 ORDER BY 1; granted | relation | pid | mode | virtualtransaction | virtualxid ---------+-----------------------------------------+-------+-----------------+--------------------+------------ f | eric_enodeb_cell_metrics | 17248 | AccessShareLock | 27/1755026 | ts=# SELECT granted, relation::regclass, pid, mode, virtualtransaction, virtualxid FROM pg_locks WHERE relation='eric_enodeb_cell_metrics'::regclass ORDER BY 1; --pid=17248 virtualxid='22/4317099' ORDER BY 1,2,3; granted | relation | pid | mode | virtualtransaction | virtualxid ---------+--------------------------+-------+--------------------------+--------------------+------------ f | eric_enodeb_cell_metrics | 22961 | AccessShareLock | 31/1337307 | f | eric_enodeb_cell_metrics | 17248 | AccessShareLock | 27/1755026 | f | eric_enodeb_cell_metrics | 28357 | AccessShareLock | 28/1118276 | f | eric_enodeb_cell_metrics | 21846 | AccessExclusiveLock | 29/830016 | f | eric_enodeb_cell_metrics | 16592 | AccessExclusiveLock | 18/38156962 | f | eric_enodeb_cell_metrics | 18941 | AccessShareLock | 32/838769 | t | eric_enodeb_cell_metrics | 530 | ShareUpdateExclusiveLock | 16/38159763 | (7 rows) ts=# SELECT pid, state, left(query,199) FROM pg_stat_activity WHERE pid IN(530,17248); 530 | active | ALTER TABLE eric_enodeb_cell_metrics* ALTER start_time SET STATISTICS 400 17248 | active | SELECT c.tableoid, c.oid, c.relname, (SELECT pg_catalog.array_agg(acl ORDER BY row_n) FROM (SELECT acl, row_n FROM pg_catalog.unnest(coalesce(c.relacl,pg_catalog.acldefault( CASE WHEN c.relkind = 'S' ts=# SELECT granted, pid, mode, virtualtransaction, virtualxid FROM pg_locks WHERE relation='eric_enodeb_cell_20180304'::regclass ; granted | pid | mode | virtualtransaction | virtualxid ---------+-------+--------------------------+--------------------+------------ t | 20488 | ShareUpdateExclusiveLock | 19/28401734 | f | 530 | ShareUpdateExclusiveLock | 16/38159763 | ts=# SELECT pid, state, left(query,199) FROM pg_stat_activity WHERE pid=20488; pid | state | left -------+--------+------------------------------------------------------------------------------------------------------------------------------------------- 20488 | active | CREATE INDEX CONCURRENTLY index_1113966210 ON eric_enodeb_cell_20180304 USING btree (site_id) WITH (fillfactor='100') TABLESPACE oldindex ts=# SELECT granted, pid, relation::regclass, locktype, mode virtualxid, virtualxid, virtualtransaction FROM pg_locks WHERE pid=20488 ORDER BY 1; granted | pid | relation | locktype | virtualxid | virtualxid | virtualtransaction ---------+-------+---------------------------+------------+--------------------------+-------------+-------------------- f | 20488 | | virtualxid | ShareLock | 22/4317099 | 19/28401734 ts=# SELECT granted, pid, relation::regclass, locktype, mode virtualxid, virtualtransaction FROM pg_locks WHERE virtualxid='22/4317099' ORDER BY 1; granted | pid | relation | locktype | virtualxid | virtualtransaction ---------+-------+----------+------------+---------------+-------------------- f | 20488 | | virtualxid | ShareLock | 19/28401734 t | 6471 | | virtualxid | ExclusiveLock | 22/4317099 (2 rows) So...I gather ALTER SET STATS is waiting on pg_dump which is waiting on CREATE INDEX which is waiting on SELECT pg_export_snapshot(), which I take to mean that I should avoid running pg_repack until the backup is finished.. ts=# SELECT pid, state, application_name app, left(query,99) FROM pg_stat_activity ORDER BY xact_start LIMIT 9; pid | state | app | left -------+---------------------+-----------+----------------------------------------------------------------------------------------------------- 6471 | idle in transaction | psql | SELECT pg_export_snapshot(); 20488 | active | pg_repack | CREATE INDEX CONCURRENTLY index_1113966210 ON eric_enodeb_cell_20180304 USING btree (site_id) WITH 530 | active | psql | ALTER TABLE eric_enodeb_cell_metrics* ALTER start_time SET STATISTICS 400 17248 | active | pg_dump | SELECT c.tableoid, c.oid, c.relname, (SELECT pg_catalog.array_agg(acl ORDER BY row_n) FROM (SELECT Justin