Re: Deduplicate code updating ControleFile's DBState. - Mailing list pgsql-hackers

From Bharath Rupireddy
Subject Re: Deduplicate code updating ControleFile's DBState.
Date
Msg-id CALj2ACWBgfyZni4xW7wGMQ+j9t_qvu+QEmpLKAkY-=OOE2C-JQ@mail.gmail.com
Whole thread Raw
In response to Re: Deduplicate code updating ControleFile's DBState.  (Amul Sul <sulamul@gmail.com>)
Responses Re: Deduplicate code updating ControleFile's DBState.
List pgsql-hackers
On Fri, Nov 26, 2021 at 2:48 PM Amul Sul <sulamul@gmail.com> wrote:
> >     ControlFile.state = DB_SHUTDOWNED;
> > -   ControlFile.time = (pg_time_t) time(NULL);
> > This one had better not be removed, either, as we require pg_resetwal
> > to guess a set of control file values.  Removing the one in
> > RewriteControlFile() is fine, on the contrary.
>
> My bad, sorry for the sloppy change, corrected it in the attached version.

Thanks for the patch. By moving the time update to update_controlfile,
the patch ensures that we have the correct last updated time. Earlier
we were missing (in some places) to update the time before calling
UpdateControlFile.

Isn't it better if we update the ControlFile->time at the end of the
update_controlfile, after file write/sync?

Why do we even need UpdateControlFile which just calls another
function? It may be there for usability and readability, but can't the
pg backend code just call update_controlfile(DataDir, ControlFile,
true); directly so that a function call cost can be avoided?
Otherwise, why can't we make UpdateControlFile an inline function? I'm
not sure if any of the compilers will ever optimize by inlining it
without the "inline" keyword.

Regards,
Bharath Rupireddy.



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Correct handling of blank/commented lines in PSQL interactive-mode history
Next
From: Bharath Rupireddy
Date:
Subject: Re: Unnecessary delay in streaming replication due to replay lag