Skip to content
dbexplore

PostgreSQL 19

PostgreSQL 19 renamed the buffer wait events

For anyone whose dashboards, alerts or session-history queries filter on wait event names.

Reference page, revised in place. Last updated .

Which filters stop matching, and how to find them before the upgrade

If a dashboard, an alert or a session-history query on your fleet mentions the wait event type BufferPin, or the event BufferPin or BufferContent, it returns nothing on PostgreSQL 19. Nothing errors. The strings are still valid text; the server never reports them.

The change is listed among the incompatibilities under Migration to Version 19 in the PostgreSQL 19 release notes: the type was renamed, the pin event was renamed, and the content event was removed in favour of three that say which kind of lock the process wanted. The wait event tables for 19 carry the new names and descriptions.

The same catalog question on both majors

pg_wait_events has existed since 17, so the cleanest comparison is to ask each server what it calls its buffer waits.

SELECT type, name
FROM pg_wait_events
WHERE type IN ('BufferPin', 'Buffer') OR name IN ('BufferPin', 'BufferContent')
ORDER BY type, name;

On 18:

   type    |     name      
-----------+---------------
 BufferPin | BufferPin
 LWLock    | BufferContent
(2 rows)

On 19:

  type  |         name         
--------+----------------------
 Buffer | BufferCleanup
 Buffer | BufferExclusive
 Buffer | BufferShared
 Buffer | BufferShareExclusive
(4 rows)

Two details in the 18 answer explain most of what goes wrong. The pin wait had a type to itself, and the content wait was not a buffer type at all: it was filed under LWLock, with the other lightweight locks. On 19 all four events sit under one type, Buffer. So the change moves time between types as well as renaming it. A panel that charts the share of time spent in LWLock waits can show a drop at the upgrade that has nothing to do with contention getting better, because the buffer content waits left that type and arrived in a new one the panel does not draw.

The descriptions on 19 say what the split buys.

SELECT name, description
FROM pg_wait_events
WHERE type = 'Buffer'
ORDER BY name;
         name         |                                                                                 description                                                                                 
----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 BufferCleanup        | Waiting to acquire an exclusive pin on a buffer. Buffer pin waits can be protracted if another process holds an open cursor that last read data from the buffer in question
 BufferExclusive      | Waiting to acquire an exclusive lock on a buffer
 BufferShared         | Waiting to acquire a shared lock on a buffer
 BufferShareExclusive | Waiting to acquire a share exclusive lock on a buffer
(4 rows)

Where 18 said only that a process was waiting to access a data page, 19 says which lock mode it wanted: shared, share exclusive, or exclusive. That is more useful once queries know the names, because the two ends point at different problems. Sessions piling up in BufferExclusive on one index typically mean writers contending for the same pages, such as inserts that all land at the end of an index on an ascending key. Sessions piling up in BufferShared typically mean readers held up while someone else holds those pages exclusively.

Filters written for 18, run on 19

The usual way a rule encodes these waits is a pair of literals. Asked of the catalog, that rule matches two events on 18 and none on 19.

SELECT count(*) AS old_pairs_known
FROM pg_wait_events
WHERE (type, name) IN (('BufferPin', 'BufferPin'), ('LWLock', 'BufferContent'));

On 18:

 old_pairs_known 
-----------------
               2
(1 row)

On 19:

 old_pairs_known 
-----------------
               0
(1 row)

There is a second trap for anyone who updates a filter from the release notes alone. The notes spell the types in capitals, renaming BUFFERPIN to BUFFER, while the activity view and the catalog report mixed case.

SELECT count(*) FILTER (WHERE type IN ('BUFFERPIN', 'BUFFER')) AS as_release_notes_spell_it,
       count(*) FILTER (WHERE type IN ('BufferPin', 'Buffer'))  AS as_the_server_reports_it
FROM pg_wait_events;

On 18:

 as_release_notes_spell_it | as_the_server_reports_it 
---------------------------+--------------------------
                         0 |                        1
(1 row)

On 19:

 as_release_notes_spell_it | as_the_server_reports_it 
---------------------------+--------------------------
                         0 |                        4
(1 row)

A case-sensitive comparison copied from the notes matches nothing on either major, which is the same silent zero for a different reason.

A real pin wait, before and after

A catalog listing proves the names; it does not prove what a waiting session looks like. This block makes one. A cursor holds a pin on the first page of a small table, and VACUUM (FREEZE) needs an exclusive pin on that page to freeze its rows, so it waits. dblink plays the two sessions.

CREATE EXTENSION dblink;
CREATE TABLE parcels (parcel_id int PRIMARY KEY, label text);
INSERT INTO parcels SELECT g, 'parcel ' || g FROM generate_series(1, 1000) AS g;
SELECT dblink_connect('cursor_holder', 'dbname=' || current_database()),
       dblink_connect('freezer',       'dbname=' || current_database());
SELECT dblink_exec('cursor_holder', 'BEGIN');
SELECT dblink_exec('cursor_holder', 'DECLARE c CURSOR FOR SELECT * FROM parcels');
SELECT * FROM dblink('cursor_holder', 'FETCH 1 FROM c') AS r(parcel_id int, label text);
SELECT dblink_send_query('freezer', 'VACUUM (FREEZE) parcels');
SELECT pg_sleep(2);
SELECT wait_event_type, wait_event, query
FROM pg_stat_activity
WHERE datname = current_database() AND query LIKE 'VACUUM%';
SELECT dblink_exec('cursor_holder', 'COMMIT');
SELECT * FROM dblink_get_result('freezer') AS r(status text);

On 18:

CREATE EXTENSION
CREATE TABLE
INSERT 0 1000
 dblink_connect | dblink_connect 
----------------+----------------
 OK             | OK
(1 row)

 dblink_exec 
-------------
 BEGIN
(1 row)

  dblink_exec   
----------------
 DECLARE CURSOR
(1 row)

 parcel_id |  label   
-----------+----------
         1 | parcel 1
(1 row)

 dblink_send_query 
-------------------
                 1
(1 row)

 pg_sleep 
----------
 
(1 row)

 wait_event_type | wait_event |          query          
-----------------+------------+-------------------------
 BufferPin       | BufferPin  | VACUUM (FREEZE) parcels
(1 row)

 dblink_exec 
-------------
 COMMIT
(1 row)

 status 
--------
 VACUUM
(1 row)

On 19:

CREATE EXTENSION
CREATE TABLE
INSERT 0 1000
 dblink_connect | dblink_connect 
----------------+----------------
 OK             | OK
(1 row)

 dblink_exec 
-------------
 BEGIN
(1 row)

  dblink_exec   
----------------
 DECLARE CURSOR
(1 row)

 parcel_id |  label   
-----------+----------
         1 | parcel 1
(1 row)

 dblink_send_query 
-------------------
                 1
(1 row)

 pg_sleep 
----------
 
(1 row)

 wait_event_type |  wait_event   |          query          
-----------------+---------------+-------------------------
 Buffer          | BufferCleanup | VACUUM (FREEZE) parcels
(1 row)

 dblink_exec 
-------------
 COMMIT
(1 row)

 status 
--------
 VACUUM
(1 row)

On 18 the vacuum is in BufferPin/BufferPin; on 19 it is in Buffer/BufferCleanup. This is the case to test first in any rule set. A vacuum that has to process a page an open cursor still holds, as the freezing vacuum here does, waits behind it for as long as the cursor stays open, and an alert written for that goes quiet at the upgrade with nothing to say it has stopped matching.

One related name did not change. The standby conflict counter for queries cancelled over pinned buffers is still confl_bufferpin in pg_stat_database_conflicts on both majors, so a recovery-conflict panel needs no edit while the wait panel beside it does.

SELECT confl_bufferpin
FROM pg_stat_database_conflicts
WHERE datname = current_database();

Both majors answer with the same column and, on a primary with no standby traffic, the same zero:

 confl_bufferpin 
-----------------
               0
(1 row)

Checking a rule set against the server you are moving to

The fix we use is a coverage check at upgrade time, in two parts. The primary check is the pair query from earlier: list each type and name pair your rules match on, and count which pairs the target server knows. It works on pairs because that is how rules match, and because a release can move an event between types as well as rename it, as 19 did with the buffer content wait. The second part, below, is a quick sweep for any type or name the target server does not know at all. Each costs one query and needs nothing more than the list.

SELECT rule_name
FROM (VALUES ('BufferPin'), ('BufferContent'), ('BufferMapping'), ('WalSync')) AS rules(rule_name)
WHERE rule_name NOT IN (SELECT type FROM pg_wait_events UNION SELECT name FROM pg_wait_events)
ORDER BY rule_name;

On 18:

 rule_name 
-----------
(0 rows)

On 19:

   rule_name   
---------------
 BufferContent
 BufferPin
(2 rows)

An empty answer on the old major and a non-empty one on the new major is the whole migration list for this change. Run it the other way round and it shows the events your rules have never heard of. Across the whole catalog that is hundreds of rows on any major, so narrow it to the type you care about:

SELECT name
FROM pg_wait_events
WHERE type = 'Buffer'
  AND name NOT IN (SELECT rule_name
                   FROM (VALUES ('BufferPin'), ('BufferContent'), ('BufferMapping'), ('WalSync')) AS rules(rule_name))
ORDER BY name;
         name         
----------------------
 BufferCleanup
 BufferExclusive
 BufferShared
 BufferShareExclusive
(4 rows)

All four buffer events come back, which is the list of names a rule set written for 18 has to learn. We would rather run this than read release notes for wait events, because the notes describe the change and the catalog is the thing your queries actually meet.

For session-history data that spans the upgrade, map both vocabularies to one bucket at query time instead of rewriting history: treat BufferPin, Buffer, and the LWLock event BufferContent as buffer access. The trade-off is that the bucket throws away the lock-mode split that 19 just added, so keep the raw names alongside it for anything recorded after the upgrade. Active session history is where those samples and their grouping are built, and lock contention and blocking trees covers the heavyweight lock waits, which this release did not rename. The catalog these queries rely on is described in the page on pg_wait_events.

What reading the new names costs

Nothing new. The wait columns in pg_stat_activity are filled whether or not anyone looks, there is no setting to enable, and pg_wait_events reads the server’s own list of events. The only cost is the edit to every query that names the old strings, and the work of finding them, which is what the coverage check is for.

Put every Postgres you run on autopilot.

We onboard teams in small batches. Tell us about your fleet and we will reach out when a seat opens. One email, no drip campaign.