<div dir="ltr">Hi all,<div><br></div><div>I have the following PostgreSQL cluster configuration:</div><div>- 3 Postgres nodes with PostgreSQL 12.4-1 running on Debian Stable with Repmgr 5.1.0</div><div>- 3 PgPool nodes with PgPool-II 4.1.1 on CentOS 8</div><div><br></div><div>PgPool is configured with master_slave_mode on, replication_mode off and load_balance_mode off.</div><div><br></div><div>This is the nodes status:</div><div>================================================</div><div>bash-4.4$ psql -h 127.0.0.1 -p 5432 -U repmgr -c "show pool_nodes;"<br></div><div> node_id | hostname  | port | status | lb_weight |  role   | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change  <br>---------+-----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------<br> 0       | postgres1 | 5432 | up     | 0.333333  | standby | 0          | false             | 0                 |                   |                        | 2020-12-07 14:16:34<br> 1       | postgres2 | 5432 | up     | 0.333333  | primary | 299        | true              | 0                 |                   |                        | 2020-12-07 14:16:34<br> 2       | postgres3 | 5432 | up     | 0.333333  | standby | 0          | false             | 0                 |                   |                        | 2020-12-07 14:16:34<br>(3 rows)<br></div><div>================================================<br></div><div><br></div><div>When I create a new database I get the following errors if I try to connect it in the same script after the CREATE statement:</div><div>================================================</div><div># psql -f psql.sql -U testuser -h proxy -d postgres -a<br>Password for user testuser: <br>DROP DATABASE test;<br>DROP DATABASE<br>CREATE DATABASE test WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';<br>CREATE DATABASE<br>ALTER DATABASE test OWNER TO postgres;<br>ALTER DATABASE<br>\connect test<br>psql:psql_no_sleep_without_sets.sql:4: \connect: ERROR:  unable to read message kind<br>DETAIL:  kind does not match between master(45) slot[1] (53)<br></div><div>================================================<br></div><div><br></div><div>On the PostgreSQL slave nodes (not on the primary one!) I see this error:</div><div>================================================<br></div><div>testuser@test FATAL:  database "test" does not exist<br></div><div>================================================<br></div><div><br></div><div>If I add a pg_sleep(0.05) after the ALTER DATABASE it works:</div><div>================================================<br></div><div># psql -f psql_with_sleep.sql -U testuser -h proxy -d postgres -a<br></div><div>Password for user testuser: <br></div><div>DROP DATABASE test;<br>DROP DATABASE<br>CREATE DATABASE test WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';<br>CREATE DATABASE<br>ALTER DATABASE test OWNER TO postgres;<br>ALTER DATABASE<br>select pg_sleep(0.05);<br> pg_sleep <br>----------<br> <br>(1 row)<br><br>\connect test<br>psql (11.7 (Debian 11.7-0+deb10u1), server 12.4 (Debian 12.4-1.pgdg100+1))<br>WARNING: psql major version 11, server major version 12.<br>         Some psql features might not work.<br>You are now connected to database "test" as user "testuser".<br></div><div>================================================<br></div><div><br></div><div>The strange thing is that if I run the same script (without sleep) on the PosgtreSQL primary node (postgres2), bypassing PgPool, it works.</div><div><br></div><div>Another strange thing is that when I run the script on PgPool, the CREATE DATABASE statement takes 4-5 seconds, but if I run directly on PostgreSQL primary node it is run immediately.</div><div><br></div><div>Could you help me to understand what's going on, please?</div><div>Thank you very much!</div><div>Bye</div><div><br></div><div><br></div><div><br></div><div><br></div></div>