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

PostgreSQL 15 preview - 流复制协议增强, READ_REPLICATION_SLOT 支持 physical slot, pg_receivewal支持slot位点了

原创 digoal 2022-01-20
361

作者

digoal

日期

2021-10-26

标签

PostgreSQL , slot , pg_receivewal , 流复制协议


PostgreSQL 15做纯wal的流式物理备份更加简单了, 因为pg_receivewal 支持了slot. 此前重启位点取决于pg_receivewal 自己在本地写wal文件时的文件名后缀partial, 而无法从上游slot中获取位点.

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=b4ada4e19fd7bedb433e46516ccd0ca4213d2719

Add replication command READ_REPLICATION_SLOT  
author  Michael Paquier <michael@paquier.xyz>     
Sun, 24 Oct 2021 22:40:42 +0000 (07:40 +0900)  
committer   Michael Paquier <michael@paquier.xyz>     
Sun, 24 Oct 2021 22:40:42 +0000 (07:40 +0900)  
commit  b4ada4e19fd7bedb433e46516ccd0ca4213d2719  
tree    2b75aeb117daecb677e200aa29fd36d801ef94e8    tree  
parent  70bef494000e4dbbeca0f0a40347ca1747aea701    commit | diff  
Add replication command READ_REPLICATION_SLOT  
The command is supported for physical slots for now, and returns the  
type of slot, its restart_lsn and its restart_tli.  
This will be useful for an upcoming patch related to pg_receivewal, to  
allow the tool to be able to stream from the position of a slot, rather  
than the last WAL position flushed by the backend (as reported by  
IDENTIFY_SYSTEM) if the archive directory is found as empty, which would  
be an advantage in the case of switching to a different archive  
locations with the same slot used to avoid holes in WAL segment  
archives.  
Author: Ronan Dunklau  
Reviewed-by: Kyotaro Horiguchi, Michael Paquier, Bharath Rupireddy  
Discussion: https://postgr.es/m/18708360.4lzOvYHigE@aivenronan  

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=f61e1dd2cee6b1a1da75c2bb0ca3bc72f18748c1

Allow pg_receivewal to stream from a slot's restart LSN  
author  Michael Paquier <michael@paquier.xyz>     
Tue, 26 Oct 2021 00:30:37 +0000 (09:30 +0900)  
committer   Michael Paquier <michael@paquier.xyz>     
Tue, 26 Oct 2021 00:30:37 +0000 (09:30 +0900)  
commit  f61e1dd2cee6b1a1da75c2bb0ca3bc72f18748c1  
tree    d7b636d11bc014ae29eb2ff32b5878b4dbb3b6d6    tree  
parent  8781b0ce25e702ba4a4f032d00da7acdef8dbfe1    commit | diff  
Allow pg_receivewal to stream from a slot's restart LSN  
Prior to this patch, when running pg_receivewal, the streaming start  
point would be the current location of the archives if anything is  
found in the local directory where WAL segments are written, and  
pg_receivewal would fall back to the current WAL flush location if there  
are no archives, as of the result of an IDENTIFY_SYSTEM command.  
If for some reason the WAL files from pg_receivewal were moved, it is  
better to try a restart where we left at, which is the replication  
slot's restart_lsn instead of skipping right to the current flush  
location, to avoid holes in the WAL backed up.  This commit changes  
pg_receivewal to use the following sequence of methods to determine the  
starting streaming LSN:  
- Scan the local archives.  
- Use the slot's restart_lsn, if supported by the backend and if a slot  
is defined.  
- Fallback to the current flush LSN as reported by IDENTIFY_SYSTEM.  
To keep compatibility with older server versions, we only attempt to use  
READ_REPLICATION_SLOT if the backend version is at least 15, and  
fallback to the older behavior of streaming from the current flush  
LSN if the command is not supported.  
Some TAP tests are added to cover this feature.  
Author: Ronan Dunklau  
Reviewed-by: Kyotaro Horiguchi, Michael Paquier, Bharath Rupireddy  
Discussion: https://postgr.es/m/18708360.4lzOvYHigE@aivenronan  

期望 PostgreSQL 增加什么功能?

类似Oracle RAC架构的PostgreSQL已开源: 阿里云PolarDB for PostgreSQL云原生分布式开源数据库!

PostgreSQL 解决方案集合

德哥 / digoal's github - 公益是一辈子的事.

digoal's wechat

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

评论