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 1vLXHS-002emt-2q for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Nov 2025 01:46:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vLXHP-009ljR-0D for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Nov 2025 01:46:43 +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 1vLXHO-009ljH-2S for pgsql-hackers@lists.postgresql.org; Wed, 19 Nov 2025 01:46:43 +0000 Received: from mail-qv1-xf36.google.com ([2607:f8b0:4864:20::f36]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vLXHM-000HHC-0q for pgsql-hackers@lists.postgresql.org; Wed, 19 Nov 2025 01:46:42 +0000 Received: by mail-qv1-xf36.google.com with SMTP id 6a1803df08f44-88051279e87so65853786d6.3 for ; Tue, 18 Nov 2025 17:46:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763516798; x=1764121598; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zu28H+O2W04bfPEBUxgMDiNXOydqUhfT7Kdl5OOYWfU=; b=HjxcImcZn9KeJBQz9LPVYEaMB8CFuLWA95WnwbaLhT+bQwwKMXCzzK8xPIuNblXjtz CPyzOoZ6Y2/mtIOWlwZ99M8ioiVPp9LrhLlHgzwg70Ze4Zod6WyiXg8rKbYRsZ0RPi8q BWemAVdPgNtO+FHJ7rbc71Tcdi6Lo1AM7wTVRhV/F6aqdAPBvM3nLaPd5RaqCNhj0/tg OpsluC1Xut4ZMAgZCq40OGjc/bRzGA4MnSC31Ez5PQEp4BaCoY7fuSWZKqcNs0JO/TLs 1zVgOY+2ACb9h64jzlB7EP5E6e/PULx1sTyOEArV04yP79sliLGkaABHPjv3sY0h0HCo Vl7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763516798; x=1764121598; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zu28H+O2W04bfPEBUxgMDiNXOydqUhfT7Kdl5OOYWfU=; b=XXl8sINYfhRMlAjTEbRSny/X4+dAjegmVlQSIluYOYkuzeIlci+6jJFiQFdutUzru4 4Ahkip3RhugaVNmYVin4SXqeco+g+WiFAaWyqFmr5XvI3xW3yu95g5+Wb6x0T6kWlx8s Ww/D5GWo1emFfua+wOtUyoYcOvsMfGnNGFejVPLqXZRo6eot6Ag9alYJ8DR1dhzK9Mzr Nj/YmMx6K5llYiZ3DkgSE2r12s4ZUSpLcPYTC1xNW6Adk8S6XVZQ5i+3Rrku00Ww1vi6 IKg7WIWCecErfnFd6g3RxyMepjb+CODOxyAoHlWdAyhczToCEbsyMEsPF4eUfLiAvtl3 NAYw== X-Forwarded-Encrypted: i=1; AJvYcCUqf3pSJc86EA1TwF6GVlb30KRg1NdsbwZYP/NAwhplT/3EtDAx5kChHtyhZUVqI9bl0tVjl0UUeqDslLns@lists.postgresql.org X-Gm-Message-State: AOJu0Yzhq1T+QSeeFnMC/hletRdGYObKaYjzJOLbJI+tOWRuMLhi0mdu /34AIfPMrKZotSidJx5evj97tNXrGQrVMk9miXSogVwlRBdc/KkoMu+O X-Gm-Gg: ASbGnctvUxt/6PekOQ4uGdzVF6YGFGkam6f2Li2wfW1TvOg6tf3OojaVUx92esgIGbO 6ahAXewWswa8Amitm7/ZkPGA9U748aq4GqhnPKRUFiOSAA2h74DO29HE+SswQkHrlmjhG5G5J4+ 986o/tOIQw239hmAy6KQKqWJ+y8TmylBx2UknjwiEE9gHsT12s2en1br16XNk19Gbd+YgolZwSW ug2HhIH1uY43kZlP3AZ6m8wkk9xx73lBpIJZLGGbO2xnCQshuM8PVlZ8Aa/IgwO5yd17NtJ828/ 4zrf/BM2HpMjtQMR5shZ2BEAfMD+0g5Fs635EMC1DuR6AQ1diXY4CUtCUxOS7JzceiKKmrif7yN Csdb2oqk0DjyE8BPGjGeqQYo/GpNgUjrcGotX5Io5xy1/ZM9wAkJR5q+LhBsq/U2rqOqcffCJKl IJ6dZJJjLaO6GJKLOuPeHsSZoF2BtbAbc= X-Google-Smtp-Source: AGHT+IH35rLWyiyYkDgfcPn/VaUnfeyyi+uvkjDJ4hN1ImItK/8vYJRSBiPtOheT1t5snM+VTSbetQ== X-Received: by 2002:a05:6214:624:b0:87c:1fd9:da52 with SMTP id 6a1803df08f44-882925ba3ebmr254066586d6.9.1763516797804; Tue, 18 Nov 2025 17:46:37 -0800 (PST) Received: from smtpclient.apple ([209.127.78.222]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-88286312406sm124950386d6.19.2025.11.18.17.46.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Nov 2025 17:46:37 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: Eagerly evict bulkwrite strategy ring From: Chao Li In-Reply-To: Date: Wed, 19 Nov 2025 09:45:59 +0800 Cc: Nazir Bilal Yavuz , Kirill Reshke , PostgreSQL Hackers , Andres Freund Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Melanie Plageman X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Melanie, I remember I ever reviewed this patch. But when I revisit v7, I just got = a confusion to clarify. > On Nov 19, 2025, at 03:13, Melanie Plageman = wrote: >=20 > On Mon, Nov 3, 2025 at 3:06=E2=80=AFPM Melanie Plageman > wrote: >>=20 >> I found an incorrect assert in CleanVictimBuffer() that was tripping >> in CI. Attached v6 is updated with it removed. >=20 > v7 rebased over recent changes in bufmgr.c >=20 > - Melanie > = 0001 only changes =E2=80=9Cgoto" to =E2=80=9Cfor=E2=80=9D, thus it's = supposed no logic change. In the old code: ``` if (strategy !=3D NULL) { XLogRecPtr lsn; /* Read the LSN while holding buffer header lock = */ buf_state =3D LockBufHdr(buf_hdr); lsn =3D BufferGetLSN(buf_hdr); UnlockBufHdr(buf_hdr); if (XLogNeedsFlush(lsn) && StrategyRejectBuffer(strategy, = buf_hdr, from_ring)) { LWLockRelease(content_lock); UnpinBuffer(buf_hdr); goto again; } } ``` It only retries when XLogNeedsFlush(lsn) is true. In the patch, everything are merged into StrategyRejectBuffer(): ``` if (StrategyRejectBuffer(strategy, buf_hdr, = from_ring)) { LWLockRelease(content_lock); UnpinBuffer(buf_hdr); continue; } ``` When StrategyRejectBuffer(strategy, buf_hdr, from_ring) is true, retry = happens. However, look into the function: ``` bool StrategyRejectBuffer(BufferAccessStrategy strategy, BufferDesc *buf, = bool from_ring) { XLogRecPtr lsn; if (!strategy) return false; /* We only do this in bulkread mode */ if (strategy->btype !=3D BAS_BULKREAD) return false; /* Don't muck with behavior of normal buffer-replacement = strategy */ if (!from_ring || strategy->buffers[strategy->current] !=3D = BufferDescriptorGetBuffer(buf)) return false; LockBufHdr(buf); lsn =3D BufferGetLSN(buf); UnlockBufHdr(buf); if (XLogNeedsFlush(lsn)) return false; ``` When XLogNeedsFlush(lsn) is true, StrategyRejectBuffer returns false, = thus no retry will happen, which is different from the old logic, is = that an intentional change? Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/