Avoid unnecessary end-of-recovery barrier waits Commit 67c20979ce7 made end-of-recovery processing emit a process signal barrier and wait for all processes to refresh their cached logical WAL logging state. This can hold up promotion indefinitely if a backend cannot process the barrier, for example while blocked sending data to a client that has stopped reading.
At wal_level=logical, logical WAL logging is enabled regardless of the cached state, so no cache synchronization is needed. Skip emitting and waiting for the barrier in this case. When logical decoding will be disabled after recovery, stale caches can only cause extra logical information to be written to WAL, which is safe. Still emit the barrier so processes update their caches asynchronously, but no longer wait for it to complete. These changes allow promotion to finish without waiting for unresponsive backends to process this barrier in either case. Retain the wait in other cases, even if the shared state has not changed, to prevent processes with stale caches from omitting required logical information after recovery. Reported-by: shihao zhong <[email protected]> Author: Fujii Masao <[email protected]> Author: Manuel Reyes Bravo <[email protected]> Reviewed-by: Masahiko Sawada <[email protected]> Discussion: https://postgr.es/m/cagrkxqtobk9c2spagha-kcgxjhvwn90j1scyuxrvydq51lk...@mail.gmail.com Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/239c4d306990b4099d16336267f0612501193e75 Modified Files -------------- src/backend/replication/logical/logicalctl.c | 33 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-)
