Re: Elimination of the repetitive code at the SLRU bootstrap functions. - Mailing list pgsql-hackers

From Evgeny
Subject Re: Elimination of the repetitive code at the SLRU bootstrap functions.
Date
Msg-id 57af7397-e436-48b1-a449-fb4012ce1cc1@gmail.com
Whole thread Raw
In response to Re: Elimination of the repetitive code at the SLRU bootstrap functions.  (Álvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-hackers
Hello hackers!

 > I think the overall idea here is good, but I didn't like the new
 > WriteSlruZeroPageXlogRec helper function; it looks too much like a
 > modularity violation (same for the fact that you have to pass the rmid
 > and info from each caller into slru.c). I would not do that in slru.c
 > but instead in every individual caller, and have this helper function in
 > xloginsert.c where it can be caller XLogSimpleInsert or something like
 > that.

Thank you Alvaro! I got your ideas and have tried to implement them.

In the v4 patch version:
1) WriteSlruZeroPageXlogRec has been renamed into XLogSimpleInsert and 
moved to the xloginset.c.

2) With the purpose of excluding passing any resource manager’s 
information into the slru.c module I propose to pass into the 
BootStrapSlruPage the XLogInsertFunc parameter pointing to a function 
accomplishing insertion of an XLog record. Implementations of these 
functions are enclosed in a corresponding slru-page module (commit_ts.c, 
multixaxt.c and so on). It preserves original modularity - the 
BootStrapSlruPage and the slru.c still do not know anything about 
resource managers. If the XLogInsertFunc parameter equals zero, 
BootStrapSlruPage will not try to perform XLog recording.

3) In addition, let’s also implement in the BootStrapSlruPage a new 
parameter writePage. It commands whether to write a page onto a disk or 
not. As a result, the BootStrapSlruPage become apt to be used in a 
larger number of places of code.

 > Also, please do not document a bunch of functions together in a single
 > comment. Instead, have one comment for each function.
 > This is not our style, and I don't think it's very ergonomical.

I got it. And since
4) The SimpleLruZeroAndLogPage is subject to deletion now.
comments are formatted as well.

 > sometimes I read source from bottom to top
Probably, we all should profess this approach!

Best regards,
Evgeny Voropaev,
Tantor Labs LLC.

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Adding a '--two-phase' option to 'pg_createsubscriber' utility.
Next
From: Pavel Stehule
Date:
Subject: Re: psql \dh: List High-Level (Root) Tables and Indexes