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 1w10mO-002Phc-1n for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 11:34:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w10mM-003XUw-1k for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 11:34:07 +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.96) (envelope-from ) id 1w10mM-003XUn-0q for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2026 11:34:06 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w10mK-00000002S9c-1Cnh for pgsql-hackers@postgresql.org; Fri, 13 Mar 2026 11:34:06 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-7d76a331ebbso1370423a34.0 for ; Fri, 13 Mar 2026 04:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773401642; cv=none; d=google.com; s=arc-20240605; b=QUKW60/xyjgo4O6VfY1Vg7s5BYFCJX9oRIgBpObDIVxVik1ToZtYxvsaGlIoCFYJmk 278E2PJjbPStQDMY9+wp05v2zBhpD8iSNYTHGhdZ60Rvb5ilhJ6dfW2AGlJIcf0Y0fCH 1H+W1xfddGeelEn8uW4bvqoZn5t4nyM1JnY6nrEADqTzRTwpak43WG3gRV1lf01wyUOz p/u3fm3/5VsLt9y5qFwF2HUYqHr1lBBswe28cNbcXl/5w/fd/jws6TBlGUsB39AyDCJa ZS2Y0ol0SFji4tqHxVi5xo5n0FEHPnydO5GWEPsSh6VjMPzkVCjHwr4ShMT5+zp+kxsf Q47A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=aGzGNqZu4e9nk3yTE2gfHW7eZdoejwf2DUdszFtX1FY=; fh=ks+uTWGlztBcc6tuw7BGQIbMNC0CWm8szWszuWYDndw=; b=gTKV4C0lVp1PyXgypV8zyLLNT1gyRCpx34fE/0Wv36fO1R4HwvHKP/dKEN1fwsEf48 ACsZ4I9S3+1qm68deepDRN5Cbho1HqPUVFK+uLykndntlTSyelUpNgzC48u1WGpaHZat OoJghxDiO8dbI1cpIZ2vMd2sI+1pB7J/t6ZET5ZvNTrv2vEIAROuGMwLQB4flj1lRTJk l7bt82Dnd3+KiVIauYygX07xTSEtxwc6HjZ1JQAOemOIVBljTTfP2vlX1pMOKjBiooFE Da1PRq2iRQOGRl3ShrIdRSxAkwnoVH0w00CS/m45UBuqvg2kUyo4W/CBFDUgxW9hQBDI i2nA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773401642; x=1774006442; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=aGzGNqZu4e9nk3yTE2gfHW7eZdoejwf2DUdszFtX1FY=; b=aVsEFony3QXBQnGMRyxYFYwE1w5W2uBeNlcvPq8ObtGsortbGaUn4EqVdFvHmYipYf bMFvHg/v8EnhVzfkzFmHad9+4YsLo8SPeSWCoKdfTcw7KwHsM8NtaXKicmqmIsfUfLFH hrXcRCS6lBv3OXhMRhaMAJncgWo5XrWputslop0J1OMnfIon7gqzR2Z6n1WY+F7YX/yo /fD6NX4A7AgpyP5Fld4YfJZIt2qwht+C+hMn+iNWSZmfjoKp02yNfNgNxPIHKWu0dpOO jj2z5PvsA06RpYA0FYtbrCShcj9GVR8fWujSrWmgVoQctr6HmxR3dulTzeKsMR2qe9UU geJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773401642; x=1774006442; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=aGzGNqZu4e9nk3yTE2gfHW7eZdoejwf2DUdszFtX1FY=; b=H1eDnM6j9va79GEQlEQZ5D1oGbeDmgdpzA25wgA5+ZtZpZElYQr+ag46ttErUbWG9A yFGBfH1PJAUodFnNo7JSv9ge1zcshrVM2dPaV+yzeGVv/oAMXOaovxWzHh/xLLMYJHLD 3REGwtizX80GmWzCEj3LG9eOPs1tc3mTYdEwIohBH9i24K/yMCtWvf93taFAdIXFNk4P 70GNBrZVTNuvyzKMoTbcquhUuwA/tVfZlJqTuIi0CV3iVTX3Av2Qnfwgk7ostbROff/p OiUpapkzxL1D94oKLkBKmQWzjBIGf8MtiVniO6UQYgfTAGBcgFHNqOVv9oIjKa33W3w+ J0UA== X-Forwarded-Encrypted: i=1; AJvYcCWPaONnGdqipP0OsY89fSKx7IzRM2VaaQp8yu5DK2RLQ6a0lP8m8wp5nWSN1ZVA/oHVz8NAExQj4pM0gBeJ@postgresql.org X-Gm-Message-State: AOJu0YwO4fcj85Mxe2b8w90oVslxWYT0UxRBD8tzUhR0hJIpPfMFIfQI ul2oMnlll9E8v01YdCtOsJVdGo7cO+BkHKfxHI0G+9lLKazv9HmlceyKkIJBZJzFr65vlgA6obz 5y+7jKzTofPL3P9h3SgmAKdErfvXjv0kdPzk3C/yKLw== X-Gm-Gg: ATEYQzyCLn2FSZ7s28k1gltLosp2UUNuvO6g7gdAWvRfIZnR7PI+CVeshNmewKhTpQY QfFN/jz2g3bCp/QqEUnBj/x5tzFtZDyvJfF2Ztq71tHjgasl/WM26vH16di+MgtDmGWn2KwnLAf nn8D48I5QX3BmNolIBfZxnuf4q0M6Q80BZJNXSHVHISYLYDIQ7Dedyzht+U3/CzmDnwMD2KXUQ7 mwLp2MU8dIT0tLyiPvrSekTK9uqcLPsPtnIaT3VMOeVL5LnK+xedoxhVqCPKlxd8YHd/XgRiQkk dvOP9iVFbMkAi3v7QzNQMq0asSesHIjULUeycWiMNw== X-Received: by 2002:a05:6820:2904:b0:67b:b6d2:6d62 with SMTP id 006d021491bc7-67bdaa2fb8dmr2003048eaf.43.1773401642184; Fri, 13 Mar 2026 04:34:02 -0700 (PDT) MIME-Version: 1.0 References: <20260305185203.76.noahmisch@microsoft.com> <2nctrio6nf4efkumjp77nx2hs5poi7vvg6avq3ftb6ssprtcog@wzuehzrfisez> <0d2e13f5-45eb-4ab1-9bce-cffb9e5754ac@vondra.me> In-Reply-To: <0d2e13f5-45eb-4ab1-9bce-cffb9e5754ac@vondra.me> From: Fujii Masao Date: Fri, 13 Mar 2026 20:33:50 +0900 X-Gm-Features: AaiRm53JpmK3Fm-9TdLNohh5tZMOf7YNkPhduoBymkuzQDVOPlJqwCbwAWxXbXI Message-ID: Subject: Re: gistGetFakeLSN() can return incorrect LSNs To: Tomas Vondra Cc: Andres Freund , Noah Misch , pgsql-hackers@postgresql.org, Tomas Vondra , Peter Geoghegan 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 On Fri, Mar 13, 2026 at 8:12=E2=80=AFPM Tomas Vondra wrot= e: > > On 3/5/26 21:25, Andres Freund wrote: > > Hi, > > > > On 2026-03-05 10:52:03 -0800, Noah Misch wrote: > >> On Thu, Mar 05, 2026 at 12:10:11PM -0500, Andres Freund wrote: > >>> Tomas encountered a crash with the index prefetching patchset. One of= the > >>> patches included therein is a generalization of the gistGetFakeLSN() > >>> mechanism, which is then used by other indexes as well. That trigger= ed an > >>> occasional, hard to locally reproduce, ERROR or PANIC in CI, about > >>> > >>> ERROR: xlog flush request 0/01BD2018 is not satisfied --- flushed o= nly to 0/01BD2000 > >> > >>> To be safe, this code would need to use a version of GetXLogInsertRec= Ptr() > >>> that does use XLogBytePosToEndRecPtr() instead of XLogBytePosToRecPtr= (). > >> > >> I agree. Thanks for diagnosing it. Feel free to move forward with th= at > >> strategy, or let me know if you'd like me to do it. > > > > I'd appreciate if you could do it. > > > > Here's a fix for master (and backpatching). It introduces a new function > GetXLogInsertEndRecPtr() and then uses that in gistGetFakeLSN(). I still > need to test this a bit more, but it did fix the issue in our dev branch > (where we saw regular failures). So I'm 99% sure it's fine. > > After writing the fix I had the idea to grep for GetXLogInsertRecPtr > calls that might have similar issue (being passed to XLogFlush), and > sure enough walsender does this: > > XLogFlush(GetXLogInsertRecPtr()); > > Which AFAICS has the same issue, right? Funnily enough, this is a very > new call, from 2026/03/06. Before 6eedb2a5fd88 walsender might flush not > far enough, now it may be flushing too far ;-) AFAIK it should call the > same GetXLogInsertEndRecPtr() once we have it. Yes, this is already being discussed at [1], and Anthonin has also proposed a patch there that adds GetXLogInsertEndRecPtr(). Regards, [1] https://postgr.es/m/vzguaguldbcyfbyuq76qj7hx5qdr5kmh67gqkncyb2yhsygrdt@= dfhcpteqifux --=20 Fujii Masao