mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
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
This commit is contained in:
@@ -288,7 +288,6 @@ extern bool RecoveryIsPaused(void);
|
||||
extern void SetRecoveryPause(bool recoveryPause);
|
||||
extern TimestampTz GetLatestXTime(void);
|
||||
extern TimestampTz GetCurrentChunkReplayStartTime(void);
|
||||
extern char *XLogFileNameP(TimeLineID tli, XLogSegNo segno);
|
||||
|
||||
extern void UpdateControlFile(void);
|
||||
extern uint64 GetSystemIdentifier(void);
|
||||
|
@@ -152,6 +152,10 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader;
|
||||
/* Length of XLog file name */
|
||||
#define XLOG_FNAME_LEN 24
|
||||
|
||||
/*
|
||||
* Generate a WAL segment file name. Do not use this macro in a helper
|
||||
* function allocating the result generated.
|
||||
*/
|
||||
#define XLogFileName(fname, tli, logSegNo, wal_segsz_bytes) \
|
||||
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, \
|
||||
(uint32) ((logSegNo) / XLogSegmentsPerXLogId(wal_segsz_bytes)), \
|
||||
|
Reference in New Issue
Block a user