暂无图片
暂无图片
2
暂无图片
暂无图片
暂无图片

理解PostgreSQL中的restartpoint重启点

原创 多米爸比 2021-08-11
2441
  1. 什么是restartpoint重启点?
    重启点(restartpoint)是否就是一种检查点(checkpoint)呢,或者这两个词其实表达的是一个事儿。
  2. 重启点什么时候创建呢?
    重启点是否与检查点类似每隔五分钟触发呢(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文件都已恢复完成时可以触发清除从主库传输到备库上的归档文件,以免备库磁盘被撑爆。

最后修改时间:2022-10-23 09:30:59
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论