mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Remove InitXLOGAccess().
It's not great that RecoveryInProgress() calls InitXLOGAccess(), because a status inquiry function typically shouldn't have the side effect of performing initializations. We could fix that by calling InitXLOGAccess() from some other place, but instead, let's remove it altogether. One thing InitXLogAccess() did is initialize wal_segment_size, but it doesn't need to do that. In the postmaster, PostmasterMain() calls LocalProcessControlFile(), and all child processes will inherit that value -- except in EXEC_BACKEND bulds, but then each backend runs SubPostmasterMain() which also calls LocalProcessControlFile(). The other thing InitXLOGAccess() did is update RedoRecPtr and doPageWrites, but that's not critical, because all code that uses them will just retry if it turns out that they've changed. The only difference is that most code will now see an initial value that is definitely invalid instead of one that might have just been way out of date, but that will only happen once per backend lifetime, so it shouldn't be a big deal. Patch by me, reviewed by Nathan Bossart, Michael Paquier, Andres Freund, Heikki Linnakangas, and Álvaro Herrera. Discussion: http://postgr.es/m/CA+TgmoY7b65qRjzHN_tWUk8B4sJqk1vj1d31uepVzmgPnZKeLg@mail.gmail.com
This commit is contained in:
@ -624,25 +624,14 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize local process's access to XLOG.
|
||||
* If this is either a bootstrap process nor a standalone backend, start
|
||||
* up the XLOG machinery, and register to have it closed down at exit.
|
||||
* In other cases, the startup process is responsible for starting up
|
||||
* the XLOG machinery, and the checkpointer for closing it down.
|
||||
*/
|
||||
if (IsUnderPostmaster)
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
/*
|
||||
* The postmaster already started the XLOG machinery, but we need to
|
||||
* call InitXLOGAccess(), if the system isn't in hot-standby mode.
|
||||
* This is handled by calling RecoveryInProgress and ignoring the
|
||||
* result.
|
||||
*/
|
||||
(void) RecoveryInProgress();
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* We are either a bootstrap process or a standalone backend. Either
|
||||
* way, start up the XLOG machinery, and register to have it closed
|
||||
* down at exit.
|
||||
*
|
||||
* We don't yet have an aux-process resource owner, but StartupXLOG
|
||||
* and ShutdownXLOG will need one. Hence, create said resource owner
|
||||
* (and register a callback to clean it up after ShutdownXLOG runs).
|
||||
|
Reference in New Issue
Block a user