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.96) (envelope-from ) id 1w00c0-001WUF-1S for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Mar 2026 17:11:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w00by-004qVT-2c for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Mar 2026 17:11:15 +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.96) (envelope-from ) id 1w00bx-004qVK-2a for pgsql-hackers@lists.postgresql.org; Tue, 10 Mar 2026 17:11:15 +0000 Received: from fhigh-a3-smtp.messagingengine.com ([103.168.172.154]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w00bw-00000001Tqo-0wEX for pgsql-hackers@postgresql.org; Tue, 10 Mar 2026 17:11:13 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id EA1B7140020B; Tue, 10 Mar 2026 13:11:10 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Tue, 10 Mar 2026 13:11:10 -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:subject:subject:to:to; s=fm1; t=1773162670; x=1773249070; bh=iz9a9kABKT96SNvayGNF4FoV20iUUwQq6iy5O+YjRxA=; b= WIYXHBQASvRKF+N/mlcE9j5uj5GL3LVxOfGMZjyByqXLOWSftt+5Q1C4vrRP2/+d MbbhKTxRYINEu9+e2Xm8PawGuR/f/q9KG3XyhZICg8g0Qh1rPe4cwjDwyeRQcC0R 7LWJ9/SmBPqTXnwacid4XyTZhZo4Roy5VzQh3NBiqQzunZVpQbMTLtW51Jzu+TDg 2aNAg/2FQ5MyaMDNj5CEexW52KgXyv9ZY0NRqYNbOdsU+dRkWUHrHVkMIdL0i+5Q pcieK5mRS42peVLGlPSJY6qR6203sChhXL5pk5TU75waGWxvmc+lv0TiasW/x805 g13HE3okVD+cbi8EaSxH5w== 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:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1773162670; x= 1773249070; bh=iz9a9kABKT96SNvayGNF4FoV20iUUwQq6iy5O+YjRxA=; b=1 AnytpfyjimTjSf3geLKG9asVBusOzK7QabBsPu0cLIWM32G9BYeeQSdxPnnJGEkP bEK4t0PJUkJJEBUIALh4MONUbPG/CwvnPmVbPA221vFUzqXPM5BMLt/Lx24WtKI6 psu4G9iYBQ4+cH6Rgejo8w53jiKa2ncljE0LRpuMsyA2t8Bi/Qa9GEsF8tAZ68NA 5715qjrgI7L7Wkj6c0v+bT4Ep8x7NyITLjNaFToRkpDbIOlR2mWK695TnU0nx7aj obeCDyXLDyp0PoFWMHwxtYxwWdO/X8T9RR0rv6tHGm5CxRHTDxSMikE9qrIzESv1 Q5ywxdlbipPYe8fR4F0Wg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeduheekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggugfgjsehtkefstddttdejnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpeeluefgueegfeevvddttddtieegveelkeetgfeuhefhvdfhueetudehhfdt gffgieenucffohhmrghinhepphhoshhtghhrrdgvshenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghlrdgu vgdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprg hnthhhohhnihhnrdgsohhnnhgvfhhohiesuggrthgrughoghhhqhdrtghomhdprhgtphht thhopegvgigtlhhushhiohhnsehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrshgroh drfhhujhhiihesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgv rhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 10 Mar 2026 13:11:10 -0400 (EDT) Date: Tue, 10 Mar 2026 13:11:09 -0400 From: Andres Freund To: Fujii Masao Cc: Anthonin Bonnefoy , Alexander Lakhin , PostgreSQL Hackers Subject: Re: Shutdown indefinitely stuck due to unflushed FPI_FOR_HINT record Message-ID: References: <2631a3c3-5e60-4a1a-9e20-377024322602@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-03-06 16:48:06 +0900, Fujii Masao wrote: > On Fri, Mar 6, 2026 at 8:46 AM Fujii Masao wrote: > > > > On Thu, Mar 5, 2026 at 5:40 PM Anthonin Bonnefoy > > wrote: > > > So it was relying on GetInsertRecPtr() instead of > > > GetXLogInsertRecPtr(). As mentioned in the thread, GetInsertRecPtr() > > > only returns the position of the last full xlog page, meaning it > > > doesn't fix the issue we have where the last partial page contains a > > > continuation record. > > > > > > Testing the XLogFlush(GetInsertRecPtr()) patch with my script, I still > > > get the shutdown stuck issue. > > > > > > Using GetXLogInsertRecPtr() is required to make sure the last partial > > > page is correctly flushed. > > > > Since GetXLogInsertRecPtr() returns a bogus LSN and XLogFlush() does > > almost nothing during recovery, I added a !RecoveryInProgress() check > > as follows. I've attached the latest version of the patch and updated > > the commit message. > > > > - if (got_STOPPING) > > - XLogBackgroundFlush(); > > + if (got_STOPPING && !RecoveryInProgress()) > > + XLogFlush(GetXLogInsertRecPtr()); > > I've pushed the patch. Thanks! I'm pretty sure this is not correct as-is, it suffers from the same issue as https://postgr.es/m/vf4hbwrotvhbgcnknrqmfbqlu75oyjkmausvy66ic7x7vuhafx%40e4rvwavtjswo I.e. it is not safe to use GetXLogInsertRecPtr() to determine up to where to flush to, due to page boundaries. Greetings, Andres Freund