Dear Amit, > I have pushed the revert. Attached patch fixes the race without taking > lock on pg_subscription_rel.
Thanks for posting the patch. I confirmed that if ALTER SEQUENCE REFRESH SEQUENCES are called twice, the second call would wait till the seqencesync worker exits. As you told, the command will acquire the AccessExclusiveLock for the subscription object thus it could be blocked till the sequencesync worker releases the same lock, typically it finishes the transaction. One concern was that CHECK_FOR_INTERRUPTS() is not called at the beginning of the batch loop(), but it won't cause the large issue: upcoming walrcv_exec() handles that. The main code LGTM. I did not check the test code though. Best regards, Hayato Kuroda FUJITSU LIMITED
