Remove XLogFileNameP() from the tree
authorMichael Paquier <michael@paquier.xyz>
Tue, 3 Dec 2019 06:06:04 +0000 (15:06 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 3 Dec 2019 06:06:04 +0000 (15:06 +0900)
commit9989d37d1c8dff12f20a1de8e1f470093136c893
tree692862e0df5056c07d0a2f4e5c7ed61dfffaaa0b
parente5532f194c18e6c12c3aa9cb07291973dc8adb39
Remove XLogFileNameP() from the tree

XLogFileNameP() is a wrapper routine able to build a palloc'd string for
a WAL segment name, which is used for error string generation.  There
were several code paths where it gets called in a critical section,
where memory allocation is not allowed.  This results in triggering
an assertion failure instead of generating the wanted error message.

Another, more annoying, problem is that if the allocation to generate
the WAL segment name fails on OOM, then the failure would be escalated
to a PANIC.

This removes the routine and all its callers are replaced with a logic
using a fixed-size buffer.  This way, all the existing mistakes are
fixed and future ones are prevented.

Author: Masahiko Sawada
Reviewed-by: Michael Paquier, Álvaro Herrera
Discussion: https://postgr.es/m/CA+fd4k5gC9H4uoWMLg9K_QfNrnkkdEw+-AFveob9YX7z8JnKTA@mail.gmail.com
src/backend/access/transam/xlog.c
src/backend/access/transam/xlogutils.c
src/backend/replication/walreceiver.c
src/backend/replication/walsender.c
src/include/access/xlog.h
src/include/access/xlog_internal.h