此条目与较新PostgreSQL版本中已重命名的功能相关
pg_last_wal_receive_lsn() 是一个系统函数,它返回流复制备用服务器已接收并同步到磁盘的最新 WAL 位置。
pg_last_wal_receive_lsn() 函数于 PostgreSQL 9.0 中添加,当时名为 pg_last_xlog_receive_location()。
用法
pg_last_wal_receive_lsn() → pg_lsn
变更历史
- PostgreSQL 10
- 重命名为
pg_last_wal_receive_lsn()(提交 806091c9)
- 重命名为
- PostgreSQL 9.0
- 作为
pg_last_xlog_receive_location()添加(提交 40f908bd)
- 作为
示例
pg_last_wal_receive_lsn() 的基本用法示例
postgres=# SELECT pg_last_wal_receive_lsn(); pg_last_wal_receive_lsn ------------------------- 7/9E1F09B8 (1 row)
此值也通过备用服务器在上游节点 pg_stat_replication 条目中的 sent_lsn 列报告。
postgres=# SELECT sent_lsn FROM pg_stat_replication WHERE application_name='node2'; replay_lsn ------------ 7/9E1F09B8 (1 row)
参考资料
- PostgreSQL 文档: 恢复控制函数
