Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qlWw6-003D9X-IC for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Sep 2023 15:58:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qlWv6-000peU-IW for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Sep 2023 15:57:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qlWv6-000peG-4q for pgsql-hackers@lists.postgresql.org; Wed, 27 Sep 2023 15:57:48 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qlWv3-007uyl-Bh for pgsql-hackers@postgresql.org; Wed, 27 Sep 2023 15:57:48 +0000 Received: from [192.168.1.115] (dsl-hkibng22-54f8db-125.dhcp.inet.fi [84.248.219.125]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4Rwh8R0zZHz49Q0F; Wed, 27 Sep 2023 18:57:43 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1695830263; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T/kNw0PymrEr9L1QdkCqqrjgyIwfb7Y2avCNkacb/TA=; b=HQIURUiDmFg4MlAWbEytDum9MPG6BXHtBY/w6XK6Mx8wAGUhogI0i9gPKyzVh3smL3iTKz TYdngO3oCd67tiRpd8oG0NXtN7vdtPP1zkF8utVG9h5UrwdswTkXzvmgoRJz+Ez2jZ6b5q LKFWNVpTLhwJtqsipukE19ihUyxFCCbazZ+Z9f453sjE9quLnzN9sLKEaJpYwM7DXeSONm kxryoQ9yQw3bjkYfE/T3nKxEv3+ob5kUNzLV+zk3HzNepISPM7Rz+V7PjBQLDUNEtfYrfX qfT8/5JEmjTTbbytZz5/DlaiNswCM19v1ZFYyZNKmLIW533JbBMVeEUZH8aGeg== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1695830263; a=rsa-sha256; cv=none; b=PNzQg40Q7PKQpFXBLO2C5LkQwUlsGsBJ5Tik35S5YPcM4KleFQggXZ9+mD9SPYV4c/cPHS jrAA2j0rlTrF41+tp+jWPdeVBApInk9xBpafCONzCF7NUy73h0IPA/Xji7LADoZrsWCp1g tio5HkFEdOSa2Iv0cfGrX7IksigNTn7u3GkNfmHIZtahANSWw5atrSpCTDPRri2tzSfLI+ Gbxf79tQ66G6yXGWzbqkOudqLy8RYjcbQOgV6xVsYPk0VaXMZd1yfjHo3Yalb4ChaPuUmR MpS+cxvIgQxCT+yKkpK6e0MQ34g6WzswCyK3udOqyKNo4HDDAP9i4AcT1Phd1Q== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1695830263; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T/kNw0PymrEr9L1QdkCqqrjgyIwfb7Y2avCNkacb/TA=; b=XmRINhcK1SbMovjL+9ukOLN3LXTaNHjzTJJijoL8WPx+xmczJckUK/O/8FfzQkmZXRpmIf mM1i3hXgjeD0YqRAKWrrn8+/DU9uVb6dmITBUu9QhaAcOJ7lT0O2MaTzvcMRUJK3RICYMM yCPHHUq7i9amKpazVwERlW7Dm/jIt8gd/IoO6doyy+IPrZOeV47Ogmb9T7HEOQb4eoEBxU FhWTbJOB9+ui0zt47dC5y8MNay7zEZ/t0X9OjsjkNWMF0Kjeoe6TzOeLVFkp/2uHkZdWvi 25EHgsUAyRUcrpCCKrgZaXPehP3TN6xnpc6oVCnujzlZgCWRJOmEuEl/Fye1Nw== Message-ID: <6d23aff2-7151-65b1-528b-2189ffa6e2df@iki.fi> Date: Wed, 27 Sep 2023 18:57:42 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: Is this a problem in GenericXLogFinish()? Content-Language: en-US To: Robert Haas , Jeff Davis Cc: pgsql-hackers@postgresql.org References: <25104133-7df8-cae3-b9a2-1c0aaa1c094a@iki.fi> <399492009193fa2c37a61b630e4449546a550039.camel@j-davis.com> <146426fc662f88604c700a72a3833b1919922f9e.camel@j-davis.com> <08b4f1f7dcf321d38373f06acc65a8d62cc2f017.camel@j-davis.com> From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 27/09/2023 18:47, Robert Haas wrote: > On Wed, Sep 27, 2023 at 11:03 AM Jeff Davis wrote: >> So it looks like it's intentionally registering a clean buffer so that >> it can take a cleanup lock for reasons other than cleaning (or even >> modiying) the page. I would think that there's a better way of >> accomplishing that goal, so perhaps we can fix that? > > I had forgotten some of the details of how this works until you > reminded me, but now that you've jarred my memory, I remember some of > it. > > When Amit Kaplla and I were working on the project to add WAL-logging > to hash indexes, we ran into some problems with concurrency control > for individual buckets within the hash index. Before that project, > this was handled using heavyweight locks, one per bucket. That got > changed in 6d46f4783efe457f74816a75173eb23ed8930020 for the reasons > explained in that commit message. Basically, instead of taking > heavyweight locks, we started taking cleanup locks on the primary > bucket pages. I always thought that was a little awkward, but I didn't > quite see how to do better. I don't think that I gave much thought at > the time to the consequence you've uncovered here, namely that it > means we're sometimes locking one page (the primary bucket page) > because we want to do something to another bucket page (some page in > the linked list of pages that are part of that bucket) and for that to > be safe, we need to lock out concurrent scans of that bucket. > > I guess I don't know of any easy fix here. :-( That seems OK. Maybe there would be a better way to do that, but there's nothing wrong with that approach per se. We could define a new REGBUF_NO_CHANGE flag to signal that the buffer is registered just for locking purposes, and not actually modified by the WAL record. -- Heikki Linnakangas Neon (https://neon.tech)