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 1q1eFJ-0007Dq-1t for pgsql-hackers@arkaria.postgresql.org; Wed, 24 May 2023 02:29:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q1eFG-0005BF-7x for pgsql-hackers@arkaria.postgresql.org; Wed, 24 May 2023 02:28:58 +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 1q1eFF-00058F-Aw for pgsql-hackers@lists.postgresql.org; Wed, 24 May 2023 02:28:57 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q1eF7-001Ysa-L3 for pgsql-hackers@lists.postgresql.org; Wed, 24 May 2023 02:28:55 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id B46CE5C0071; Tue, 23 May 2023 22:28:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 23 May 2023 22:28:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type: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=fm1; t= 1684895328; x=1684981728; bh=5wq9nRCg8I/685ta23tewoyWVegW7v4QxnH qCG40iHw=; b=gNmraPaEPUqsTNlr+XUUvATXtZ8XOfLcciRXmC0Cpn2P7dqS6pg tIiMkS6tVuvofvy1wqlnFzntULe1w9SgO0d1ds1xwbnJksn/o3dJKg8tqr/Zhk2B mhkYBCtFDsTkb02znE1x5AOfg2x/BoCGRTBFAQrTduD0Ahq6u4zOZhpcJRS/6NsY svjcCrBtNejKgy7V10Ueifql+i831Wly/E2R4wPr0z9V5V//C7270b4JIC9eLp0g TX3y/hyWcCtOI+C13piIGcrLnOXu8oG8fsHZcIX8EugFTHmbgrVmNmr4B7PzU8EL 6BzpWKIKJjemIDk+zHp2ZpxjJ3rCKgHmkjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :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=fm1; t= 1684895328; x=1684981728; bh=5wq9nRCg8I/685ta23tewoyWVegW7v4QxnH qCG40iHw=; b=qTds0VN7paHUtJQmpKuGvcyDpjCOTNJrHpL8ovqV0JCgotSd7kk g0Yj4FdE1rXyFut2OIF6B26p1n6OGIrMP4f+MMk077m4PDedNx+Lk70q0oJ2G1/9 10LHwMuXmSvd/eDspCf4rEiLTdTE4aEh3lC5q0FNu9X8thBBAR0kV4FHxSwRTJDi oKX1uCwV+oqx9iHliEFwsyL4uO/o6B1tOhB55jKWF9fPq+StFdmjA6XHHRvNZelH ABZKg+P4xXrMOGUM+KalHtmbmTTcWp+gPetV+q5ec2gupkrbt6Sr0uPX6Eb9nioH taXrpmG9XiSCNVTMbjGabiHmJRGpwNNidbg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejgedgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtugfgjgesth ekredttddtjeenucfhrhhomheptehnughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshes rghnrghrrgiivghlrdguvgeqnecuggftrfgrthhtvghrnhephfeitefgleevtedtffejve dujeekjedugfdtveffjeelvddtfeekgefgjefhgfegnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdrug gv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 23 May 2023 22:28:47 -0400 (EDT) Date: Tue, 23 May 2023 19:28:45 -0700 From: Andres Freund To: Kyotaro Horiguchi Cc: thomas.munro@gmail.com, myon@debian.org, pgsql-hackers@lists.postgresql.org Subject: Re: could not extend file "base/5/3501" with FileFallocate(): Interrupted system call Message-ID: <20230524022845.mvhxg4e4nltcu74x@awork3.anarazel.de> References: <20230424223225.gle3x3sw5m4div2l@awork3.anarazel.de> <20230425001623.im5uquriqlk4ayy6@awork3.anarazel.de> <20230524.105628.2202582176350190855.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230524.105628.2202582176350190855.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2023-05-24 10:56:28 +0900, Kyotaro Horiguchi wrote: > At Wed, 26 Apr 2023 11:37:55 +1200, Thomas Munro wrote in > > On Tue, Apr 25, 2023 at 12:16 PM Andres Freund wrote: > > > On 2023-04-24 15:32:25 -0700, Andres Freund wrote: > > > > We obviously can add a retry loop to FileFallocate(), similar to what's > > > > already present e.g. in FileRead(). But I wonder if we shouldn't go a bit > > > > further, and do it for all the fd.c routines where it's remotely plausible > > > > EINTR could be returned? It's a bit silly to add EINTR retries one-by-one to > > > > the functions. > > > > > > > > > > > > The following are documented to potentially return EINTR, without fd.c having > > > > code to retry: > > > > > > > > - FileWriteback() / pg_flush_data() > > > > - FileSync() / pg_fsync() > > > > - FileFallocate() > > > > - FileTruncate() > > > > > > > > With the first two there's the added complication that it's not entirely > > > > obvious whether it'd be better to handle this in File* or pg_*. I'd argue the > > > > latter is a bit more sensible? > > > > > > A prototype of that approach is attached. I pushed the retry handling into the > > > pg_* routines where applicable. I guess we could add pg_* routines for > > > FileFallocate(), FilePrewarm() etc as well, but I didn't do that here. > > > > One problem we ran into with the the shm_open() case (which is nearly > > identical under the covers, since shm_open() just opens a file in a > > tmpfs on Linux) was that a simple retry loop like this could never > > terminate if the process was receiving a lot of signals from the > > recovery process, which is why we went with the idea of masking > > signals instead. Eventually we should probably grow the file in > > smaller chunks with a CFI in between so that we both guarantee that we > > make progress (by masking for smaller size increases) and service > > interrupts in a timely fashion (by unmasking between loops). I don't > > think that applies here because we're not trying to fallocate > > humongous size increases in one go, but I just want to note that we're > > making a different choice. I think this looks reasonable for the use > > cases we actually have here. > > FWIW I share the same feeling about looping by EINTR without signals > being blocked. If we just retry the same operation without processing > signals after getting EINTR, I think blocking signals is better. We > could block signals more gracefully, but I'm not sure it's worth the > complexity. I seriously doubt it's a good path to go down in this case. As Thomas mentioned, this case isn't really comparable to the shm_open() one, due to the bounded vs unbounded amount of memory we're dealing with. What would be the benefit? Greetings, Andres Freund