- 什么是restartpoint重启点?
重启点(restartpoint)是否就是一种检查点(checkpoint)呢,或者这两个词其实表达的是一个事儿。 - 重启点什么时候创建呢?
重启点是否与检查点类似每隔五分钟触发呢(postgresql.conf文件里配置checkpoint_timeout=5min)。
通过restartpoint关键字搜索文档,从 wal-configuration有如下描述:
In archive recovery or standby mode, the server periodically performs restartpoints, which are similar to checkpoints in normal operation: the server forces all its state to disk, updates the pg_control file to indicate that the already-processed WAL data need not be scanned again, and then recycles any old log segment files in the pg_wal directory. Restartpoints can’t be performed more frequently than checkpoints in the master because restartpoints can only be performed at checkpoint records. A restartpoint is triggered when a checkpoint record is reached if at least checkpoint_timeout seconds have passed since the last restartpoint, or if WAL size is about to exceed max_wal_size. However, because of limitations on when a restartpoint can be performed, max_wal_size is often exceeded during recovery, by up to one checkpoint cycle’s worth of WAL. (max_wal_size is never a hard limit anyway, so you should always leave plenty of headroom to avoid running out of disk space.)
在基于PITR归档恢复模式或主备模式时,服务器周期性地执行重启点,和正常操作时的检查点相似:服务器强制刷新它所有的状态到磁盘文件,更新pg_control来指示已被处理的WAL数据,并且接着回收pg_wal中的旧日志段文件。
重启点其实就是在recovery恢复期间执行的checkpoint操作,此时它执行的是重启点,并不是一个新的检查点。重启点是可以重新开始进行恢复,因为恢复操作可以被中断,下次重新开始进行恢复并不是从头开始恢复数据,而是从最近一次的重启点开始。
重启点常见使用于archive_cleanup_command:
在standby服务器上恢复触发重启点且所有需要恢复的WAL文件都已恢复完成时可以触发清除从主库传输到备库上的归档文件,以免备库磁盘被撑爆。