From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_stash_advice: Don't forget unsaved changes after a failed wri
Date: Thu, 29 Oct 2026 16:56:09 +0000
Message-ID: <E1xMTQ9-00000001HWm-0HEF@gemulon.postgresql.org> (raw)
pg_stash_advice: Don't forget unsaved changes after a failed write.
If the persistence worker hits an error while writing
pg_stash_advice.tsv, it exits and the postmaster restarts it. The new
worker doesn't think the file needs to be rewritten until something
changes or the server shuts down. Instead, it should retry the failed
write.
This also fixes a second bug. The worker should record the current
change count before, rather than after, setting stashes_ready.
Failure to do so creates a narrow window during which any changes
won't trigger the persistence worker to rewrite the file.
Zsolt's original patch included a test case, but I've left that out
here because it doesn't seem worth the cycles for a bug that seems
unlikely to be reintroduced. If others disagree, we can revisit.
Oversight in commit c10edb102ada607eb054bc9e23690109d86849ef.
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com>
Author: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Dongpo Liu <poe.liu@pm.me>
Discussion: http://postgr.es/m/CAN4CZFMoWWdXhrNRk1id=N_K4o5kae3kQTtJi__UfzrEOeUCCA@mail.gmail.com
Backpatch-through: 19
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/6f161201768d5f1a241b25ca86389e9746a94544
Modified Files
--------------
contrib/pg_stash_advice/stashpersist.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: rhaas@postgresql.org
Subject: Re: pgsql: pg_stash_advice: Don't forget unsaved changes after a failed wri
In-Reply-To: <E1xMTQ9-00000001HWm-0HEF@gemulon.postgresql.org>
References: <E1xMTQ9-00000001HWm-0HEF@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox