Skip to content

Files

Latest commit

Dec 15, 2023
f400df2 · Dec 15, 2023

History

History
91 lines (56 loc) · 4 KB

20210714_01.md

File metadata and controls

91 lines (56 loc) · 4 KB

PostgreSQL 15 preview - 内置逻辑复制sub pub支持prepared transactions

作者

digoal

日期

2021-07-14

标签

PostgreSQL , 逻辑复制 , sub , pub


背景

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

Add support for prepared transactions to built-in logical replication.   
  
master github/master  
author	Amit Kapila <akapila@postgresql.org>	  
Wed, 14 Jul 2021 02:03:50 +0000 (07:33 +0530)  
committer	Amit Kapila <akapila@postgresql.org>	  
Wed, 14 Jul 2021 02:03:50 +0000 (07:33 +0530)  
commit	a8fd13cab0ba815e9925dc9676e6309f699b5f72  
tree	bfebac6bfc2d32a9212e33f9090bd700b0316fae	tree  
parent	6c9c2831668345122fd0f92280b30f3bbe2dd4e6	commit | diff  
Add support for prepared transactions to built-in logical replication.  
  
To add support for streaming transactions at prepare time into the  
built-in logical replication, we need to do the following things:  
  
* Modify the output plugin (pgoutput) to implement the new two-phase API  
callbacks, by leveraging the extended replication protocol.  
  
* Modify the replication apply worker, to properly handle two-phase  
transactions by replaying them on prepare.  
  
* Add a new SUBSCRIPTION option "two_phase" to allow users to enable  
two-phase transactions. We enable the two_phase once the initial data sync  
is over.  
  
We however must explicitly disable replication of two-phase transactions  
during replication slot creation, even if the plugin supports it. We  
don't need to replicate the changes accumulated during this phase,  
and moreover, we don't have a replication connection open so we don't know  
where to send the data anyway.  
  
The streaming option is not allowed with this new two_phase option. This  
can be done as a separate patch.  
  
We don't allow to toggle two_phase option of a subscription because it can  
lead to an inconsistent replica. For the same reason, we don't allow to  
refresh the publication once the two_phase is enabled for a subscription  
unless copy_data option is false.  
  
Author: Peter Smith, Ajin Cherian and Amit Kapila based on previous work by Nikhil Sontakke and Stas Kelvich  
Reviewed-by: Amit Kapila, Sawada Masahiko, Vignesh C, Dilip Kumar, Takamichi Osumi, Greg Nancarrow  
Tested-By: Haiying Tang  
Discussion: https://postgr.es/m/02DA5F5E-CECE-4D9C-8B4B-418077E2C010@postgrespro.ru  
Discussion: https://postgr.es/m/CAA4eK1+opiV4aFTmWWUF9h_32=HfPOW9vZASHarT0UA5oBrtGw@mail.gmail.com  

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

digoal's wechat