Seems like the retry loop from 019_replslot_limit might help.
pgsql-hackers by date:
Соглашаюсь с условиями обработки персональных данных