简体   繁体   中英

Understanding the effects of deleting pg_wal in postgres

Our database crashed lately due WAL files filling up space. I figured out the source of the issue after the fact, but for a quick solution since we already had a separate/recent backup of the database, I deleted the pg_wal folder.

From what I understand, this can cause some issues with pg_basebackup . Majority of research I've done has found that deleting pg_wal can result in a corrupted database.

What I don't understand is in what situation would things be corrupted?

If I delete pg_wal and then take another fresh pg_basebackup , wouldn't I still be able to restore from that backup? or does pg_basebackup rely on older wal entries to be generated properly? And if that is the case, how is it any different than restoring from pg_dump and then running pg_basebackup ?

If you delete the transaction log, which is contained in pg_wal , you have deleted an integral part of your database. You won't be able to start your database, and you might as well delete the rest of the data directory and restore your backup.

A specialist can probably still salvage most of the data, but particularly when the database had crashed, there will be data loss.

Never, ever, delete pg_wal or any other part of the data directory. The exception are the log files, which are inside the log subdirectory of the data directory if you chose the default location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM