pgsql: pg_stash_advice: Don't forget unsaved changes after a failed wri

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pg_stash_advice: Don't forget unsaved changes after a failed wri
Date: 2026-10-29 16:56:09
Message-ID: E1xMTQ9-00000001HWk-0CEU@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)parragi(at)percona(dot)com>
Author: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Reviewed-by: Dongpo Liu <poe(dot)liu(at)pm(dot)me>
Discussion: http://postgr.es/m/CAN4CZFMoWWdXhrNRk1id=N_K4o5kae3kQTtJi__UfzrEOeUCCA@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/61553eacadbca0a084c7ae46214ffdee71208823

Modified Files
--------------
contrib/pg_stash_advice/stashpersist.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2026-10-29 20:50:15 pgsql: Fix issue with code manually adjusting a TupleTableSlot
Previous Message Robert Haas 2026-10-29 15:56:49 pgsql: pg_plan_advice: Mark PARTITIONWISE inapplicable on plain rels.