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 1hnC1H-0002fk-A4 for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jul 2019 01:12: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 1hnC1G-0004vr-5h for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jul 2019 01:12:38 +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 1hnC1F-0004rk-QW for pgsql-hackers@lists.postgresql.org; Tue, 16 Jul 2019 01:12:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hnC1D-0000v5-5G for pgsql-hackers@postgresql.org; Tue, 16 Jul 2019 01:12:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x6G1CWF2004175; Mon, 15 Jul 2019 21:12:32 -0400 From: Tom Lane To: Thomas Munro cc: David Rowley , pgsql-hackers Subject: Re: Parallel Append subplan order instability on aye-aye In-reply-to: <1554.1563236463@sss.pgh.pa.us> References: <2863.1558327585@sss.pgh.pa.us> <3341.1558449552@sss.pgh.pa.us> <1588.1558500275@sss.pgh.pa.us> <1554.1563236463@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 15 Jul 2019 20:21:03 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4173.1563239552.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 15 Jul 2019 21:12:32 -0400 Message-ID: <4174.1563239552@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > So that data-collection patch has been in place for nearly 2 months > (since 2019-05-21), and in that time we've seen a grand total of > no repeats of the original problem, as far as I've seen. Oh ... wait a minute. I decided to go scrape the buildfarm logs to confirm my impression that there were no matching failures, and darn if I didn't find one: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=3Djacana&dt=3D2019= -06-04%2021%3A00%3A22 For the archives' sake, that's a pg_upgradeCheck failure, and here are the regression diffs: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D regression.diffs =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff -w -U3 c:/mingw/msys/1.0/home/pgrunner/bf/root/HEAD/pgsql.build/../pg= sql/src/test/regress/expected/select_parallel.out c:/mingw/msys/1.0/home/p= grunner/bf/root/HEAD/pgsql.build/src/bin/pg_upgrade/tmp_check/regress/resu= lts/select_parallel.out --- c:/mingw/msys/1.0/home/pgrunner/bf/root/HEAD/pgsql.build/../pgsql/src/= test/regress/expected/select_parallel.out 2019-05-21 14:00:23 -0400 +++ c:/mingw/msys/1.0/home/pgrunner/bf/root/HEAD/pgsql.build/src/bin/pg_up= grade/tmp_check/regress/results/select_parallel.out 2019-06-04 17:42:27 -0= 400 @@ -21,12 +21,12 @@ Workers Planned: 3 -> Partial Aggregate -> Parallel Append + -> Parallel Seq Scan on a_star -> Parallel Seq Scan on d_star -> Parallel Seq Scan on f_star -> Parallel Seq Scan on e_star -> Parallel Seq Scan on b_star -> Parallel Seq Scan on c_star - -> Parallel Seq Scan on a_star (11 rows) = select round(avg(aa)), sum(aa) from a_star a1; @@ -49,10 +49,10 @@ -> Parallel Append -> Seq Scan on d_star -> Seq Scan on c_star + -> Parallel Seq Scan on a_star -> Parallel Seq Scan on f_star -> Parallel Seq Scan on e_star -> Parallel Seq Scan on b_star - -> Parallel Seq Scan on a_star (11 rows) = select round(avg(aa)), sum(aa) from a_star a2; @@ -75,12 +75,12 @@ Workers Planned: 3 -> Partial Aggregate -> Parallel Append + -> Seq Scan on a_star -> Seq Scan on d_star -> Seq Scan on f_star -> Seq Scan on e_star -> Seq Scan on b_star -> Seq Scan on c_star - -> Seq Scan on a_star (11 rows) = select round(avg(aa)), sum(aa) from a_star a3; @@ -95,7 +95,7 @@ where relname like '__star' order by relname; relname | relpages | reltuples = ---------+----------+----------- - a_star | 1 | 3 + a_star | 0 | 0 b_star | 1 | 4 c_star | 1 | 4 d_star | 1 | 16 diff -w -U3 c:/mingw/msys/1.0/home/pgrunner/bf/root/HEAD/pgsql.build/../pg= sql/src/test/regress/expected/stats.out c:/mingw/msys/1.0/home/pgrunner/bf= /root/HEAD/pgsql.build/src/bin/pg_upgrade/tmp_check/regress/results/stats.= out --- c:/mingw/msys/1.0/home/pgrunner/bf/root/HEAD/pgsql.build/../pgsql/src/= test/regress/expected/stats.out 2019-05-21 14:00:23 -0400 +++ c:/mingw/msys/1.0/home/pgrunner/bf/root/HEAD/pgsql.build/src/bin/pg_up= grade/tmp_check/regress/results/stats.out 2019-06-04 17:43:06 -0400 @@ -205,7 +205,7 @@ where relname like '__star' order by relname; relname | relpages | reltuples = ---------+----------+----------- - a_star | 1 | 3 + a_star | 0 | 0 b_star | 1 | 4 c_star | 1 | 4 d_star | 1 | 16 This plan shape change matches some, though by no means all, of the previous failures. And we can now see why the planner did that: a_star has a smaller recorded size than the other tables in the query. So what happened there? There's no diff in the pg_stat_all_tables query, which proves that a vacuum on a_star did happen, since it transmitted a vacuum_count increment to the stats collector. It seems like there are two possible theories: (1) The vacuum for some reason saw the table's size as zero (whereupon it'd read no blocks and count no tuples). (2) The vacuum's update of the pg_class row failed to "take". Theory (2) seems a bit more plausible, but still very unsettling. The similar failures that this result doesn't exactly match all look, in the light of this data, like some one of the "X_star" tables unexpectedly moved to the top of the parallel plan, which we can now hypothesize means that that table had zero relpages/ reltuples after supposedly being vacuumed. So it's not only a_star that's got the issue, which lets out my half-formed theory that being the topmost parent of the inheritance hierarchy has something to do with it. But I bet that these tables forming an inheritance hierarchy (with multiple inheritance even) does have something to do with it somehow, because if this were a generic VACUUM bug surely we'd be seeing it elsewhere. regards, tom lane