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 1tzdYa-004aSt-Ij for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Apr 2025 15:29:40 +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 1tzdYZ-003qIN-5x for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Apr 2025 15:29:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tzdYY-003qHx-MB for pgsql-hackers@lists.postgresql.org; Tue, 01 Apr 2025 15:29:38 +0000 Received: from hedgehog.birch.relay.mailchannels.net ([23.83.209.81]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tzdYW-002Mnd-12 for pgsql-hackers@postgresql.org; Tue, 01 Apr 2025 15:29:37 +0000 X-Sender-Id: dreamhost|x-authsender|nico@cryptonector.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 8401A782F0B; Tue, 1 Apr 2025 15:29:34 +0000 (UTC) Received: from pdx1-sub0-mail-a303.dreamhost.com (100-126-123-24.trex-nlb.outbound.svc.cluster.local [100.126.123.24]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 1B1DE783596; Tue, 1 Apr 2025 15:29:34 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1743521374; a=rsa-sha256; cv=none; b=AC0s/nMKwh2DJvpw01a4DjJXG4SLEbJsBVkiHMqdTZTYrdEJijvzovvvaIHtq37RohGKKb AjDCpA4M9pxKjHXioJVaQbsar1pkmcuvMV8AZV+RGMMDGkEc9tEB+DmyICHpd5PIDHQb+K spmfrkfAIZHR+/QIQQ1/0gGJkW/zK1v855gCYK6ftwedkLKhZe/j5kbfY78Xwk4SEqkr9A 6le1X3eS1dOjZJI3kSbCraU4bsVLathF29U+GLD59UXd6R+2lEaiEKMgjAd3GRMsJ72kgh GOLOCoPXuwx19q+Jnedqjcj/r42+nJNP+6P+2TL9D+NwsBa6oh7mnRSRyYHTPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1743521374; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tDig49GrG1YtPrD+wnbF2888hy6PWv+A9GChpQ08gYc=; b=ZU/nUlXATqm9xTbvYMaZenMNBrev+V64OejLgofXY43WmvpmWvF+CZkjMP87tCf3/VkXN1 5XgRjeXfo9vb5hTC1YKB6FuiEmh7hNcotfTTNKrgtZ4nRyFqu8gaLPGzd4ZQg3HaWDeNDa V+L/cUeKA2XT738QCBnuC78PCCSkczsZTHS6kn46p/DFykXBE84VLOynh/MUv2aGKhycP9 lzFKWHggtO9afS6YCdry02bIsVER1Ea4tDy00q49ce2MR77DMg4N2JQxmR5jXg0j+qLwCA Cuce43kIWYR31g6FtIwf6RVDIFonGsCIkGtVV06MSUPC0d5ltDTPEh2aLDbsmg== ARC-Authentication-Results: i=1; rspamd-7668cf9b8d-td8xv; auth=pass smtp.auth=dreamhost smtp.mailfrom=nico@cryptonector.com X-Sender-Id: dreamhost|x-authsender|nico@cryptonector.com X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|nico@cryptonector.com X-MailChannels-Auth-Id: dreamhost X-Shade-Dime: 613fcffa2cecd78d_1743521374340_350836595 X-MC-Loop-Signature: 1743521374340:3779393131 X-MC-Ingress-Time: 1743521374340 Received: from pdx1-sub0-mail-a303.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.126.123.24 (trex/7.0.3); Tue, 01 Apr 2025 15:29:34 +0000 Received: from ubby (syn-075-081-095-064.res.spectrum.com [75.81.95.64]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by pdx1-sub0-mail-a303.dreamhost.com (Postfix) with ESMTPSA id 4ZRsP93WSVzLG; Tue, 1 Apr 2025 08:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cryptonector.com; s=dreamhost; t=1743521373; bh=tDig49GrG1YtPrD+wnbF2888hy6PWv+A9GChpQ08gYc=; h=Date:From:To:Cc:Subject:Content-Type; b=SOoqExn2Rw3s0+uErSef+oeQu9n4oI0CZvQLUst812fK1ScGhkL6tWzb63KpKx2Nn KXtQaVm6OKKZFrqOjLN+1lZEt3H/Ka0fn1R0IfIZItNNhXm/Z0x2r1prJfJN+ebn+U mMXyAF1HFF5AtHE76tt1TqonEHbg40FP8+aYqcSrf4Mlq4KckAAS4MDRmwmhl+37Os qTt+YjdcdsBWkD251nzQO8CRqFYQCPk2wyC5K1TfaP0SyRgm1Afoh7COuB1z0cddde beT4b7GRjgNX8Ba/rSFkwmsExv4ktGfp/2HNJuJVEjqWcj740UbwEff/u5TAhN37EK mFw8f9jIRhsPA== Date: Tue, 1 Apr 2025 10:29:31 -0500 From: Nico Williams To: Heikki Linnakangas Cc: Andres Freund , pgsql-hackers@postgresql.org Subject: Re: AIO writes vs hint bits vs checksums Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Oct 30, 2024 at 02:16:51PM +0200, Heikki Linnakangas wrote: > Acquiring the exclusive lock in step 4 is just a way to wait for all the > existing share-lockers to release the lock. You wouldn't need to block new > share-lockers. We have LW_WAIT_UNTIL_FREE, which is almost what we need, but > it currently ignores share-lockers. So doing this "properly" would require > more changes to LWLocks. Briefly acquiring an exclusive lock seems > acceptable though. The problem is starvation. For this you really want something more like rwlocks that do not have the writer starvation problem. But rwlocks have other problems too, like in this case forcing readers to wait. What you want here is something more like a barrier where readers that did not see that the page has BM_IO_IN_PROGRESS set get to act as though it's not set while readers that did see that the page has BM_IO_IN_PROGRESS set don't, and the process that did set that bit gets to wait for the first set of readers all without blocking the second set of readers. That's something akin to an rwlock, but better -- in fact, it resembles RCU. Nico --