Split xlog.c - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Split xlog.c
Date
Msg-id b3b71061-4919-e882-4857-27e370ab134a@iki.fi
Whole thread Raw
Responses Re: Split xlog.c  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Hi,

xlog.c is very large. We've split off some functions from it over the 
years, but it's still large and it keeps growing.

Attached is a proposal to split functions related to WAL replay, standby 
mode, fetching files from archive, computing the recovery target and so 
on, to new source file called xlogrecovery.c. That's a fairly clean 
split. StartupXLOG() stays in xlog.c, but much of the code from it has 
been moved to new functions InitWalRecovery(), PerformWalRecovery() and 
EndWalRecovery(). The general idea is that xlog.c is still responsible 
for orchestrating the servers startup, but xlogrecovery.c is responsible 
for figuring out whether WAL recovery is needed, performing it, and 
deciding when it can stop.

There's surely more refactoring we could do. xlog.c has a lot of global 
variables, with similar names but slightly different meanings for 
example. (Quick: what's the difference between InRedo, InRecovery, 
InArchiveRecovery, and RecoveryInProgress()? I have to go check the code 
every time to remind myself). But this patch tries to just move source 
code around for clarity.

There are small changes in the order that some of things are done in 
StartupXLOG(), for readability. I tried to be careful and check that the 
changes are safe, but a second pair of eyes would be appreciated on that.

- Heikki

Attachment

pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: unnesting multirange data types
Next
From: Daniel Gustafsson
Date:
Subject: Re: Support for NSS as a libpq TLS backend