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 <[email protected]> Author: Zsolt Parragi <[email protected]> Reviewed-by: Dongpo Liu <[email protected]> Discussion: http://postgr.es/m/CAN4CZFMoWWdXhrNRk1id=n_k4o5kae3kqttji__ufzreoeu...@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(-)
