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/
[email protected]
tmpfile)));
unlink(tmpfile);
}
- else if (rename(tmpfile, statfile) < 0)
+ else if (durable_rename(tmpfile, statfile, LOG) < 0)
{
- ereport(LOG,
- (errcode_for_file_access(),
- errmsg("could not rename temporary statistics file \"%s\" to \"%s\": %m",
- tmpfile, statfile)));
+ /* durable_rename already emitted log message */
unlink(tmpfile);
}
}