pgsql: localbuf: Track pincount in BufferDesc as well - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: localbuf: Track pincount in BufferDesc as well
Date
Msg-id E1tyd8t-001e5p-36@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
localbuf: Track pincount in BufferDesc as well

For AIO on temporary table buffers the AIO subsystem needs to be able to
ensure a pin on a buffer while AIO is going on, even if the IO issuing query
errors out. Tracking the buffer in LocalRefCount does not work, as it would
cause CheckForLocalBufferLeaks() to assert out.

Instead, also track the refcount in BufferDesc.state, not just
LocalRefCount. This also makes local buffers behave a bit more akin to shared
buffers.

Note that we still don't need locking, AIO completion callbacks for local
buffers are executed in the issuing session (i.e. nobody else has access to
the BufferDesc).

Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/uvrtrknj4kdytuboidbhwclo4gxhswwcpgadptsjvjqcluzmah%40brqs62irg4dt

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d6d8054dc72d4844f52f1552f8d3074c16987e32

Modified Files
--------------
src/backend/storage/buffer/localbuf.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)


pgsql-committers by date:

Previous
From: Andres Freund
Date:
Subject: pgsql: aio, bufmgr: Comment fixes/improvements
Next
From: Michael Paquier
Date:
Subject: Re: pgsql: pg_upgrade: Fix inconsistency in memory freeing