Skip to content

Commit ec67869

Browse files
committed
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
1 parent 4b74ebf commit ec67869

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/backend/utils/activity/pgstat.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,12 +1478,9 @@ pgstat_write_statsfile(void)
14781478
tmpfile)));
14791479
unlink(tmpfile);
14801480
}
1481-
else if (rename(tmpfile, statfile) < 0)
1481+
else if (durable_rename(tmpfile, statfile, LOG) < 0)
14821482
{
1483-
ereport(LOG,
1484-
(errcode_for_file_access(),
1485-
errmsg("could not rename temporary statistics file \"%s\" to \"%s\": %m",
1486-
tmpfile, statfile)));
1483+
/* durable_rename already emitted log message */
14871484
unlink(tmpfile);
14881485
}
14891486
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy