Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lWaef-0004mj-Kw for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Apr 2021 08:13:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lWaee-0005Fj-Hc for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Apr 2021 08:13:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lWaed-0005Dn-Rl for pgsql-hackers@lists.postgresql.org; Wed, 14 Apr 2021 08:13:44 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lWaeY-0005MY-Uo for pgsql-hackers@lists.postgresql.org; Wed, 14 Apr 2021 08:13:42 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 531A617E0 for ; Wed, 14 Apr 2021 04:13:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 14 Apr 2021 04:13:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:subject:message-id:mime-version:content-type; s= fm1; bh=qdxnfJ/oHtR8V8Pqe6U7OGPoLxF1LZkp/od4CNyT1ao=; b=DGSQV7zZ yvukwSxRAhMELPseWtCmEIJxC1Q0S5tl7TYuIt3wo/nCwsnalHySxYFFu0kcCInn OOdetB2voV9VP/OjMHXJuJagmbGfaxR+9ZGcTl9rKQPzbyJ0UYV8TyB0tO9QfTQv 98jOyIzg7ppCLSBYNgAbyNv4dCkCHFS9HsyvPhTI8JKhgmJtjY7FCj3zYnYlpLAg ry6OHsorYwr8srxPlchtdL0yEOsnZZR/PTRs7d4ehQ62ODt2pLAX7sFykXdHhC05 jJeMYB+svkVZelMGx4SkIliq7ohXYDuGePjM8IQnWfcWZtBxudY5hj4xGJmQxsrh LvkTGMpQXmqi0Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=qdxnfJ/oHtR8V8Pqe6U7OGPoLxF1L Zkp/od4CNyT1ao=; b=gzbiiOuUzGTSrv6eWmTBc5Ctnn5t8ob9Bq44OmY15wd+P yOvcidW7w7qRdnZHHFpvPiAwjfQzQftZRvArVZZyPCbnSbdklukrCh/4T1VDzDk2 xXlprUPUy5M8XBKKC4D1IIx4t9l9+fNPz48D/q+0YVz2MlfJ/acYGaIpvd31q8It scnpYR/8kMEvqTNnQWgNJQPNi1Wgy2oEM0qC+XR81nu0s0htldFQW+WI0ZP1Y2Lv WihhxXnBSivE4oJGRlvett0QDEr/ZVQglK14U7sFPhbTqK4s3RClwV2YYCC/PjX2 HrpBlmna3Pa4HclwY+agMzlN2E3pjMYn6uA0nA5aQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeluddgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdlfeehmdenucfjughrpeffhffvuffkgggtugesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeeihedvveekjeejudduheegjeeivdfh hfefgeeftdejieelgedtgeffhfetvdevtdenucffohhmrghinhepphhoshhtghhrvghsqh hlrdhorhhgnecukfhppeduuddurddutddvrddukedtrddukeehnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuih gvrhdrgiihii X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id C2DDC108005F for ; Wed, 14 Apr 2021 04:13:34 -0400 (EDT) Date: Wed, 14 Apr 2021 17:13:30 +0900 From: Michael Paquier To: Postgres hackers Subject: File truncation within PostgresNode::issues_sql_like() wrong on Windows Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Ava5bOnXrmnYgFqj" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Ava5bOnXrmnYgFqj Content-Type: multipart/mixed; boundary="8B5CzqgcWcQwD43N" Content-Disposition: inline --8B5CzqgcWcQwD43N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, As fairywren has proved a couple of days ago, it is not really a good idea to rely on a file truncation to check for patterns in the logs of the backend: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=fairywren&dt=2021-04-07%2013%3A29%3A28 Visibly, a logic based on the log file truncation fails on Windows because of the concurrent access of the backend that outputs its logs there. In PostgresNode.pm, connect_ok() and connect_access() enforce a rotation of the log file before restarting the server on Windows to make sure that a given step does not find logs generated by a previous test, but that's not the case of issues_sql_like(). Looking at the existing tests using this routine (src/bin/scripts/), I have found on test in 090_reindexdb.pl that could lead to a false positive. The test is marked in the patch attached, just for awareness. Would there be any objections to change this routine so as we avoid the file truncation on Windows? The patch attached achieves that. Any thoughts? -- Michael --8B5CzqgcWcQwD43N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="tap-sql-like-truncate.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_rei= ndexdb.pl index 159b637230..8b06218d6b 100644 --- a/src/bin/scripts/t/090_reindexdb.pl +++ b/src/bin/scripts/t/090_reindexdb.pl @@ -174,6 +174,7 @@ $node->command_fails( $node->command_fails( [ 'reindexdb', '-j', '2', '-i', 'i1', 'postgres' ], 'parallel reindexdb cannot process indexes'); +# XXX The first query maps with a test above. $node->issues_sql_like( [ 'reindexdb', '-j', '2', 'postgres' ], qr/statement:\ REINDEX SYSTEM postgres; diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index e26b2b3f30..9daa438ccc 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -2195,7 +2195,8 @@ Run a command on the node, then verify that $expected= _sql appears in the server log file. =20 Reads the whole log file so be careful when working with large log outputs. -The log file is truncated prior to running the command, however. +The log file is truncated prior to running the command, and on Windows, a +rotation of the log file is done before restarting the node. =20 =3Dcut =20 @@ -2207,7 +2208,18 @@ sub issues_sql_like =20 local %ENV =3D $self->_get_env(); =20 - truncate $self->logfile, 0; + # On Windows, the truncation would not work, so rotate the log + # file before restarting the server afresh. + if ($TestLib::windows_os) + { + $self->rotate_logfile; + $self->restart; + } + else + { + truncate $self->logfile, 0; + } + my $result =3D TestLib::run_log($cmd); ok($result, "@$cmd exit code 0"); my $log =3D TestLib::slurp_file($self->logfile); --8B5CzqgcWcQwD43N-- --Ava5bOnXrmnYgFqj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmB2pCoACgkQnvQgOdby QH0F9A//QWI4X5UEYt0ukRIAtl/ZZF4S/o2xkj/uVXgUUQYTXNt0uUlu9USs7xeD ZyRzPD3chllsa//i1Y6T63tPQni8pOCOQPUr1vPVDyC5PGPKgW7U4747rdPgks81 nsK25OkCZIVVgaHughoQiJNC+li+cYjCZIIbBYnLV4yaUOH4PYBKae2+6kAzbRbt mFHj81q2NiUZOCTiZJNp12WYGJ3cbJ4aS6Esn1vS471V9TeOW/nzgMDszSe3UFbU JD92iJ2MUmdRmCpsrFEG47ELZF1I8hvQZKQ+67ICBEeyV34Q2IROYTzwLYwkb/P1 fTlmSQJ57UpnLGW07aIP8M5o35U/xT8AVwVgI/ywLpXOBgHC18iDlESwpPNLuqmo O9fgvQQrNBp7S89vCL6nVxcFUhiyIJXd9VFA2LdR/6HZf5eh+L1s/SLztYSZ7UzI IfRHes62p6mxnfXoqNWpYIMFY1YH91Z2h6cMZr0cDHroAv06MRquY47+Ziosqduc qqMdD+7RypOThzXvWU6h7LBYDkMvdTCglSHt/kytUmihDeI+1n/gNg2Q0tiOtqZV NlfrZewIRL4CbED1pi25aUcnivi4iMMsbGiJ4+4VnPernpceCAeus6MtHxudhk0V xfMjegdoeI9XdqsQd3bcvZt77GgFPLQjKilZuV7r6tRH8kWiHIU= =MMwW -----END PGP SIGNATURE----- --Ava5bOnXrmnYgFqj--