DATABASE TECHNICAL PAPER

postgresql.log file grows infinitely, and never rotates… did your disk fill up previously?

2019-10-23 Greg Clough

An interesting (and currently undocumented) behaviour of PostgreSQL is that when there is an error writing to the postgresql.log configured in log_filename, that all future log rotations are disabled by this piece of code in syslogger.c:

if (errno != ENFILE && errno != EMFILE)
{
    ereport(LOG, (errmsg("disabling automatic rotation (use SIGHUP to re-enable)")));
    rotation_disabled = true;
}

In most default configurations this will never be noticed, because the log_directory is on the same filesystem as the data_directory. In that case the entire instance will crash, and once space is cleared then it will be restarted afresh with log rotation enabled.

If, however, you put your log_directory onto a different filesystem, then it can fill up without taking the entire cluster down. Once you clear space then logging will resume, but rotation will remain disabled.

To correct this, once some space has been cleared send a SIGHUP to the postmaster process by calling pg_reload_conf() or running pg_ctl reload.

Uncategorized

Leave a Reply

Discover more from Greg Clough's notes on PostgreSQL

Subscribe now to keep reading and get access to the full archive.

Continue reading