Make write of pgstats file durable at shutdown

Michael Paquier <michael@paquier.xyz>

Commit: ec678692f6d0a8b05b86ca08e96b51e4063cba32
Author: Michael Paquier <michael@paquier.xyz>
Date: 2024-07-17T02:50:36Z
Releases: 18.0
Make write of pgstats file durable at shutdown

This switches the pgstats write code to use durable_rename() rather than
rename().  This ensures that the stats file's data is durable when the
statistics are written, which is something only happening at shutdown
now with the checkpointer doing the job.

This could cause the statistics to be lost even after PostgreSQL is shut
down, should a host failure happen, for example.

Suggested-by: Konstantin Knizhnik
Reviewed-by: Bertrand Drouvot
Discussion: https://postgr.es/m/ZpDQTZ0cAz0WEbh7@paquier.xyz

Files

PathChange+/−
src/backend/utils/activity/pgstat.c modified +2 −5

Discussion