Created
June 14, 2025 18:09
-
-
Save cabecada/ce9d88f2d1c5ea2a021814ad0d8ac9b6 to your computer and use it in GitHub Desktop.
pgactive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get -y -q install libipc-run-perl lcov build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache pkg-config libicu-dev | |
sudo mkdir /opt/postgresql/17 | |
sudo chown -R postgres:postgres /opt/postgresql/17 | |
cd postgres | |
./configure --prefix=/opt/postgresql/17 --enable-debug --enable-cassert --enable-tap-tests --enable-coverage CFLAGS="-ggdb3 -O0" | |
make -j4 install | |
export PATH=/opt/postgresql/17/bin:$PATH | |
export PG_CONFIG=/opt/postgresql/17/bin/pg_config | |
cd contrib/ | |
make install | |
git clone https://github.com/aws/pgactive.git | |
cd pgactive | |
./configure | |
make regress_check | |
make install | |
initdb -D db1 | |
postgres@ubuntu:/tmp$ cat db1/postgresql.auto.conf | |
track_commit_timestamp = on | |
shared_preload_libraries = 'pgactive' | |
wal_level = 'logical' | |
# Force sync commit so pgactive_wait_for_slots_confirmed_flush_lsn is faster | |
# and tests run better. Note that we don't do this for | |
# TAP tests. | |
pgactive.synchronous_commit = on | |
pgactive.skip_ddl_replication = false | |
port=5432 | |
---- | |
initdb -D db2 | |
postgres@ubuntu:/tmp$ cat db2/postgresql.auto.conf | |
track_commit_timestamp = on | |
shared_preload_libraries = 'pgactive' | |
wal_level = 'logical' | |
# Force sync commit so pgactive_wait_for_slots_confirmed_flush_lsn is faster | |
# and tests run better. Note that we don't do this for | |
# TAP tests. | |
pgactive.synchronous_commit = on | |
pgactive.skip_ddl_replication = false | |
port=5433 | |
------------- | |
alias p1='psql -h localhost -p 5432 -d postgres -U postgres ' | |
alias p2='psql -h localhost -p 5433 -d postgres -U postgres ' | |
pg_ctl -D db1 -l db1.log start | |
pg_ctl -D db2 -l db2.log start | |
p1: | |
create extension pgactive; | |
\e | |
CREATE SERVER pgactive_server_endpoint1 | |
FOREIGN DATA WRAPPER pgactive_fdw | |
OPTIONS (host 'localhost', port '5432', dbname 'postgres'); | |
CREATE USER MAPPING FOR postgres | |
SERVER pgactive_server_endpoint1 | |
OPTIONS (user 'postgres'); | |
-- connection info for endpoint2 | |
CREATE SERVER pgactive_server_endpoint2 | |
FOREIGN DATA WRAPPER pgactive_fdw | |
OPTIONS (host 'localhost', port '5433', dbname 'postgres'); | |
CREATE USER MAPPING FOR postgres | |
SERVER pgactive_server_endpoint2 | |
OPTIONS (user 'postgres'); | |
p2 | |
create extension pgactive; | |
\e | |
CREATE SERVER pgactive_server_endpoint1 | |
FOREIGN DATA WRAPPER pgactive_fdw | |
OPTIONS (host 'localhost', port '5432', dbname 'postgres'); | |
CREATE USER MAPPING FOR postgres | |
SERVER pgactive_server_endpoint1 | |
OPTIONS (user 'postgres'); | |
-- connection info for endpoint2 | |
CREATE SERVER pgactive_server_endpoint2 | |
FOREIGN DATA WRAPPER pgactive_fdw | |
OPTIONS (host 'localhost', port '5433', dbname 'postgres'); | |
CREATE USER MAPPING FOR postgres | |
SERVER pgactive_server_endpoint2 | |
OPTIONS (user 'postgres'); | |
p1 | |
SELECT pgactive.pgactive_create_group( | |
node_name := 'endpoint1-app', | |
node_dsn := 'user_mapping=postgres pgactive_foreign_server=pgactive_server_endpoint1' | |
); | |
SELECT pgactive.pgactive_wait_for_node_ready(); | |
p2 | |
SELECT pgactive.pgactive_join_group( | |
node_name := 'endpoint2-app', | |
node_dsn := 'user_mapping=postgres pgactive_foreign_server=pgactive_server_endpoint2', | |
join_using_dsn := 'user_mapping=postgres pgactive_foreign_server=pgactive_server_endpoint1' | |
); | |
SELECT pgactive.pgactive_wait_for_node_ready(); | |
p1 | |
create table t(col1 int); | |
insert into t select 1; | |
p2 | |
\dt t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment