Skip to content

This would act like a Postgres replica server to consume the logical changes in server. This is for sharing in Orcas.

License

Notifications You must be signed in to change notification settings

fkfk000/replication_checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

replication_checker

This would act like a Postgres replica server to consume the logical changes in server. This is for sharing in Orcas.

Compile

This prject uses cmake to compile. To minimize the effort we need to spend during the configuration, I have decided not to include the require part. Instead, we only need

  • download pre-compiled Postgres server files.
  • download pre-compiled openssl files. and then modify the path.

Then,

mkdir bld
cd bld
cmake ..
cmake --build .

would compile the progrem

Run this program

.\Debug\replication_checker.exe user username replication database host host.postgres.database.azure.com dbname test1 password LongPassword

Then, the application will connect to database server and receving the changes. When data chnages happen in database server, the changes will be displayed by this application.

image

For exmaple, for the partioned table "tb", if we insert into some values, replication_checker will display the logical part for this table:

image

And we could see the lag from the database side (becasue we do not replay the wal files, the replay lag would just increase): image

How replication_checker works

In Postgres server, replica would connect to database server just like normal connections expcet add "replication=database" in connection string. In replication_checker, the input parameters would be pasred as "user=username replication=database host=host.postgres.database.azure.com dbname=test1 password=LongPassword".

Then, replication_checker will connect to database use the parsed connection string and looking for publication "pub" and create a subscription "sub". (this is currently hard coded, perhaps I will change in the feature)

Then, primary server will send data changes to replication_checker.

This programs supports logical replication protocols like "insert/update/delete" both in normal logical replication mode or streaming mode. For example

image

Then, in replication_checker we could have:

image

docker run

docker run -e PubName=pub -e SlotName=sub -it dog830228/replica-pg:0.5  user postgres replication database host localhost dbname postgres password test.123

About

This would act like a Postgres replica server to consume the logical changes in server. This is for sharing in Orcas.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •