Database logs no longer grow forever
The database server had been writing to a single log file since it was first set up, and that file had grown to 31 GB. It is now rotated every day and old days are compressed and cleared after two weeks. Cleaning up the old log freed about 30 GB, and the server's disk went from 29 percent used to 13 percent.
Highlights
- The database log is rotated every day instead of growing in one file
- Older days are compressed and anything past 14 days is removed
- The 31 GB log that had built up was compressed to 786 MB, about 2.5 percent of its size
- About 30 GB freed: disk use went from 55 GB (29 percent) to 25 GB (13 percent)
- Done with no restart and no interruption to sending or the dashboard
In this release2
- ImprovedSystem
Daily rotation for the database server log
Every database server keeps a log of what it is doing. Ours had never been rotated, so it was one file that had been growing since the server was first set up, adding around 65 MB a day until it reached 31 GB.
There was plenty of disk left, so nothing was failing yet. Left alone, though, it would only ever have grown, and a full disk takes the database down with it.
What we changed:
- The database started a fresh log file on the spot, without a restart, so nothing that was running was interrupted.
- The old 31 GB file was compressed in the background at the lowest priority, so it did not slow anything else down. It came down to 786 MB, and we checked the compressed copy is intact before the original was removed.
- From now on the log is rotated every day. The previous day is compressed, and anything older than 14 days is removed automatically.
31 GB0.79 GB97% lowerSize of the database log folder