public inbox for [email protected]  
help / color / mirror / Atom feed
From: Kirill Reshke <[email protected]>
To: Michael Paquier <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: Release and unpin buffers after leaving CRIT section in GIN.
Date: Tue, 17 Feb 2026 15:14:45 +0500
Message-ID: <CALdSSPj9ixr6Uf8kMs8FfcDcUWx7cQ-iysLiLJ0n-2henP1-sQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CALdSSPgBPnpNNzxv0Y+_GNFzW6PmzRZYh+_hpf06Y1N2zLhZaQ@mail.gmail.com>
	<[email protected]>

On Tue, 17 Feb 2026 at 15:07, Michael Paquier <[email protected]> wrote:
>
> On Tue, Feb 17, 2026 at 02:58:24PM +0500, Kirill Reshke wrote:
> > Few places in GIN code does not follow that. v1 fixes it.
>
> Yep.  That sounds pretty much right.  Thanks for the report.
> --
> Michael

Looks like there are two more instances of this on HEAD: in gistbuild
and log_newpage_range. Is it?

```
reshke@yezzey-cbdb-bench:~/cpg$ git diff
src/backend/access/gist/gistbuild.c
src/backend/access/transam/xloginsert.c
diff --git a/src/backend/access/gist/gistbuild.c
b/src/backend/access/gist/gistbuild.c
index 7f57c787f4c..8e0c083ffa7 100644
--- a/src/backend/access/gist/gistbuild.c
+++ b/src/backend/access/gist/gistbuild.c
@@ -305,10 +305,10 @@ gistbuild(Relation heap, Relation index,
IndexInfo *indexInfo)
                MarkBufferDirty(buffer);
                PageSetLSN(page, GistBuildLSN);

-               UnlockReleaseBuffer(buffer);
-
                END_CRIT_SECTION();

+               UnlockReleaseBuffer(buffer);
+
                /* Scan the table, inserting all the tuples to the index. */
                reltuples = table_index_build_scan(heap, index,
indexInfo, true, true,

            gistBuildCallback,
diff --git a/src/backend/access/transam/xloginsert.c
b/src/backend/access/transam/xloginsert.c
index d3acaa636c3..a9a1678acc9 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -1355,11 +1355,12 @@ log_newpage_range(Relation rel, ForkNumber forknum,
                recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI);

                for (i = 0; i < nbufs; i++)
-               {
                        PageSetLSN(BufferGetPage(bufpack[i]), recptr);
-                       UnlockReleaseBuffer(bufpack[i]);
-               }
+
                END_CRIT_SECTION();
+
+               for (i = 0; i < nbufs; i++)
+                       UnlockReleaseBuffer(bufpack[i]);
        }
 }

```

-- 
Best regards,
Kirill Reshke






view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Release and unpin buffers after leaving CRIT section in GIN.
  In-Reply-To: <CALdSSPj9ixr6Uf8kMs8FfcDcUWx7cQ-iysLiLJ0n-2henP1-sQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox