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 1nLZqL-0003eS-Es for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Feb 2022 00:12:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nLZqJ-0007mN-RI for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Feb 2022 00:12:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nLZqI-0007mD-3P for pgsql-hackers@lists.postgresql.org; Sun, 20 Feb 2022 00:12:47 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nLZqC-0006J4-Hy for pgsql-hackers@lists.postgresql.org; Sun, 20 Feb 2022 00:12:45 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id D6B3B32009DF; Sat, 19 Feb 2022 19:12:35 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 19 Feb 2022 19:12:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; bh=4sXrs9XJP4bjMQ EpEfEX4uSdgRaal0F5f5kHCOz2MZ4=; b=LPGvGA2e+4Dyf8BVAgCRqoGcYSH14y 3p+uxS9NaORpfqbHeGqdwCNntrCch4xKdmiW6OX7VOBJUdwlEbGjJBfuCLrvnqHA 2dkbakQbuiEIRLoWzjQSjvgD1WjH9L+54RkTfoRMhNE8rVrY8Gxsc11nwF6CR1nG U9PZ73Q0k6qIsbOBN7wyHNZu5KNphtc/pUk8gF56WvECCTouaPFsh6vWfG0uWDKB wM92rX7011kjoUjA4EGI7wL7WNAJf9oefJZ0iLnRsbH6AdHYXLAyZazYzT1KgbFD i4gf6MSMFsPcEVUWxUpLJYsh0LJckfJs99P+UrlweH3bO8dA27OSxhew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=4sXrs9XJP4bjMQEpEfEX4uSdgRaal0F5f5kHCOz2M Z4=; b=YRrVZ+dVd0A6TxxJko7otzbe+pUnnjmw+EXdtSiiJZvs1m/aKonT7gxYL WwF3wFVDsG0EJ0c0axcAQCkmLJMMKl3pC/VVz0BOHn4ejRjW6P9/nzOyqdntftVb Mf9p22MTWOdU+AMgRaHqS0NuppHysSnB6f3NIacFKJ5fUIeB+d4VY+DcigdxkykZ CKY56xDMrhcjoHz55H8uD/waY0MndCVJnOYBj63xHe4r4Y6bNWH5J8swrFfV7XBs Uv/N4LC6F/ltQEWyghWpa1AWRpT+DAR7LpPl1OEhVFlWjz5fGQHLo+m88ZK+3Quj N1NdtCuk+wDPHIhTyfeq7zwiBo9tA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrkeefgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvufgfjghfkfggtgfgsehtqhhmtddtreejnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpeeftddthfelhfefheehkeejgeehfeehvdfhgfdtieevudegveekleefgfdv geehvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 19 Feb 2022 19:12:34 -0500 (EST) Date: Sat, 19 Feb 2022 16:12:31 -0800 From: Andres Freund To: pgsql-hackers@lists.postgresql.org, Peter Geoghegan CC: Robert Haas , Masahiko Sawada , PostgreSQL Hackers Subject: =?US-ASCII?Q?Re=3A_Removing_more_vacuumlazy=2Ec_speci?= =?US-ASCII?Q?al_cases=2C_relfrozenxid_optimizations?= User-Agent: K-9 Mail for Android In-Reply-To: References: <20220218221117.ijozsjwaxa6fy5u6@alap3.anarazel.de> Message-ID: <87697D0B-3A41-4A5B-B9CF-85D989361E27@anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, (On phone, so crappy formatting and no source access) On February 19, 2022 3:08:41 PM PST, Peter Geoghegan wrote: >On Fri, Feb 18, 2022 at 5:00 PM Peter Geoghegan wrote: >> Another testing strategy occurs to me: we could stress-test the >> implementation by simulating an environment where the no-cleanup-lock >> path is hit an unusually large number of times, possibly a fixed >> percentage of the time (like 1%, 5%), say by making vacuumlazy=2Ec's >> ConditionalLockBufferForCleanup() call return false randomly=2E Now tha= t >> we have lazy_scan_noprune for the no-cleanup-lock path (which is as >> similar to the regular lazy_scan_prune path as possible), I wouldn't >> expect this ConditionalLockBufferForCleanup() testing gizmo to be too >> disruptive=2E > >I tried this out, using the attached patch=2E It was quite interesting, >even when run against HEAD=2E I think that I might have found a bug on >HEAD, though I'm not really sure=2E > >If you modify the patch to simulate conditions under which >ConditionalLockBufferForCleanup() fails about 2% of the time, you get >much better coverage of lazy_scan_noprune/heap_tuple_needs_freeze, >without it being so aggressive as to make "make check-world" fail -- >which is exactly what I expected=2E If you are much more aggressive >about it, and make it 50% instead (which you can get just by using the >patch as written), then some tests will fail, mostly for reasons that >aren't surprising or interesting (e=2Eg=2E plan changes)=2E This is also >what I'd have guessed would happen=2E > >However, it gets more interesting=2E One thing that I did not expect to >happen at all also happened (with the current 50% rate of simulated >ConditionalLockBufferForCleanup() failure from the patch): if I run >"make check" from the pg_surgery directory, then the Postgres backend >gets stuck in an infinite loop inside lazy_scan_prune, which has been >a symptom of several tricky bugs in the past year (not every time, but >usually)=2E Specifically, the VACUUM statement launched by the SQL >command "vacuum freeze htab2;" from the file >contrib/pg_surgery/sql/heap_surgery=2Esql, at line 54 leads to this >misbehavior=2E >This is a temp table, which is a choice made by the tests specifically >because they need to "use a temp table so that vacuum behavior doesn't >depend on global xmin"=2E This is convenient way of avoiding spurious >regression tests failures (e=2Eg=2E from autoanalyze), and relies on the >GlobalVisTempRels behavior established by Andres' 2020 bugfix commit >94bc27b5=2E We don't have a blocking path for cleanup locks of temporary buffers IIRC = (normally not reachable)=2E So I wouldn't be surprised if a cleanup lock fa= iling would cause some odd behavior=2E >It's quite possible that this is nothing more than a bug in my >adversarial gizmo patch -- since I don't think that >ConditionalLockBufferForCleanup() can ever fail with a temp buffer >(though even that's not completely clear right now)=2E Even if the >behavior that I saw does not indicate a bug on HEAD, it still seems >informative=2E At the very least, it wouldn't hurt to Assert() that the >target table isn't a temp table inside lazy_scan_noprune, documenting >our assumptions around temp tables and >ConditionalLockBufferForCleanup()=2E Definitely worth looking into more=2E This reminds me of a recent thing I noticed in the aio patch=2E Spgist can= end up busy looping when buffers are locked, instead of blocking=2E Not ac= tually related, of course=2E Andres --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E