On Tue, Aug 24, 2021 at 6:28 PM Ajin Cherian <itsa...@gmail.com> wrote: > > On Tue, Aug 24, 2021 at 9:08 PM Amit Kapila <amit.kapil...@gmail.com> wrote: > > > What happens when there is neither a new walsender nor an old > > walsender is present? It means to run the above statement when a new > > walsender is exited due to error "... slot is active ..." and before a > > new walsender could start. Also, allow old walsender (due to which the > > error occurs) to exit before executing the statement. > > > I tried this, then the query returns a null instead of 'false' because > there is no entry for that application_name. > > postgres=# select pid != 31876 from pg_stat_replication where > application_name = 'sub'; > ?column? > ---------- > (0 rows) >
But will poll function still poll or exit? Have you tried that? Because it is not clear from your explanation how in the first statement it returns a valid value which leads poll to exit and then in second statement it returns NULL or maybe nothing. Can you share the log also when you are getting "replication slot "tap_sub" is active for ..."? If you see in the below log [1], the STATEMENT is printed twice, I want to see if you also get prints in a similar way or is it something different? Do you know why it is printed twice? [1] 2021-08-15 18:44:38.027 CEST [16475:6] tap_sub LOG: received replication command: START_REPLICATION SLOT "tap_sub" LOGICAL 0/16BEEB0 (proto_version '1', publication_names '"tap_pub","tap_pub_ins_only"') 2021-08-15 18:44:38.027 CEST [16475:7] tap_sub STATEMENT: START_REPLICATION SLOT "tap_sub" LOGICAL 0/16BEEB0 (proto_version '1', publication_names '"tap_pub","tap_pub_ins_only"') 2021-08-15 18:44:38.027 CEST [16475:8] tap_sub ERROR: replication slot "tap_sub" is active for PID 16336 2021-08-15 18:44:38.027 CEST [16475:9] tap_sub STATEMENT: START_REPLICATION SLOT "tap_sub" LOGICAL 0/16BEEB0 (proto_version '1', publication_names '"tap_pub","tap_pub_ins_only"') -- With Regards, Amit Kapila.