> I tested with both 'binary = true' and 'binary = false' option while
> creating a subscription. For me replication is working fine and I am
> not getting any errors in both the cases.
> I have also attached the test script.

I modified your test script to demonstrate the problem.

I created another table before the tested one to make sure oids are
different between the nodes, and used the user-created table in the
test.

I also had to change the subscriber data type to text to get "invalid
byte sequence" error.  Still the same script works without the error
with (binary = false).

My analysis on the original post was wrong.  The subscriber handles it
as an oid.  Though, it's still not clear to me this is a desirable
behaviour for the users, because oid's of the objects differ.
#!/usr/bin/env bash

# setup publisher node
./pg_ctl stop -D ../publisher
rm -rf ../publisher publisher.log
 
mkdir ../publisher
./initdb -D ../publisher
 
cat << EOF >> ../publisher/postgresql.conf
wal_level = logical
wal_sender_timeout = 0
listen_addresses = '*'
EOF
 
./pg_ctl start -D ../publisher -l publisher.log

./psql -d postgres -c "CREATE TABLE t0 (i int);"
./psql -d postgres -c "CREATE TABLE t1 (a regclass, b regproc, c regtype);"
./psql -d postgres -c "create publication pub1 for table t1"
./psql -d postgres -c "ALTER TABLE t1 REPLICA IDENTITY FULL"
./psql -d postgres -c "INSERT INTO t1 values('t1', 64, 'int')"


# setup subscriber node
cluster_name=subscriber
./pg_ctl stop -D ../$cluster_name
 
rm -rf ../$cluster_name $cluster_name.log
 
mkdir ../$cluster_name
./initdb -D ../$cluster_name
 
cat << EOF >> ../$cluster_name/postgresql.conf
wal_level = logical
wal_receiver_timeout = 0
listen_addresses = '*'
port = 9000
EOF
./pg_ctl start -D ../$cluster_name -l $cluster_name.log

./psql -d postgres -p 9000 -c "CREATE TABLE t1 (a text, b regproc, c regtype);"
./psql -d postgres -p 9000 -c "create subscription test1 connection 'dbname=postgres host=localhost port=5432' publication pub1 with (binary = false);"
sleep 2

# operations on publisher
./psql -d postgres -c "INSERT INTO t1 values('pg_type', 64, 'int')"
./psql -d postgres -c "update t1 set c = 'text' where c = 'int'::regtype;"
./psql -d postgres -c "update t1 set a = 'pg_proc' where a = 'pg_type'::regclass"

 

Reply via email to