Re: increasing the default WAL segment size
Beena Emerson <memissemerson@gmail.com>
Attachments
- 0002-Make-wal-segment-size-configurable-at-initdb-time_v4.patch (application/octet-stream) patch v4-0002
On Wed, Sep 13, 2017 at 2:58 PM, Andres Freund <andres@anarazel.de> wrote: > Hi, > > On 2017-09-06 20:24:16 +0530, Beena Emerson wrote: >> > - pg_standby's RetrieveWALSegSize() does too much for it's name. It >> > seems quite weird that a function named that way has the section below >> > "/* check if clean up is necessary */" >> >> we set 2 cleanup related variables once WalSegSize is set, namely >> need_cleanup and exclusiveCleanupFileName. Does >> SetWALSegSizeAndCleanupValues look good? > > It's better, but see below. > > >> > - the way you redid the ReadControlFile() invocation doesn't quite seem >> > right. Consider what happens if XLOGbuffers isn't -1 - then we >> > wouldn't read the control file, but you unconditionally copy it in >> > XLOGShmemInit(). I think we instead should introduce something like >> > XLOGPreShmemInit() that reads the control file unless in bootstrap >> > mode. Then get rid of the second ReadControlFile() already present. >> >> I did not think it was necessary to create a new function, I have >> simply added the check and >> function call within the XLOGShmemInit(). > > Which is wrong. XLogShmemSize() already needs to know the actual size, > otherwise we allocate the wrong shmem size. You may sometimes succeed > nevertheless because we leave some slop unused shared memory space, but > it's not ok to rely on. See the refactoring I did in 0001. > > Changes: > - refactored the way the control file was handled, moved it to separate > phase. I wrote this last and it's late, so I'm not yet fully confident > in it, but it survives plain and EXEC_BACKEND builds. This also gets > rid of ferrying wal_segment_size through the EXEC_BACKEND variable > stuff, which didn't really do much, given how many other parts weren't > carried over. > - renamed all the non-postgres binary version of wal_segment_size to > WalSegSz, diverging seems pointless, and the WalSegsz seems > inconsistent. > - changed malloc in pg_waldump's search_directory() to a stack > allocation. Less because of efficiency, more because there wasn't any > error handling. > - removed redundant char * -> XLogPageHeader -> XLogLongPageHeader casting. > - replace new malloc with pg_malloc in initdb (failure handling!) > - replaced the floating point logic in pretty_wal_size with a, imo much > simpler, (sz % 1024) == 0 > - it's inconsistent that the new code for pg_standby was added to the > top of the file, where all the customizable stuff resides. > - other small changes > > Issues: > > - I think the pg_standby stuff isn't correct. And it's hard to > understand. Consider the case where the first file restored is *not* a > timeline history file, but *also* not a complete file. We'll start to > spew "not enough data in file" errors and such, which we previously > didn't. My preferred solution would be to remove pg_standby ([1]), > but that's probably not quick enough. Unless we can quickly agree on > that, I think we need to refactor this a bit, I've done so in the > attached, but it's untested. Could you please verify it works and if > not fix it up? > > What do you think? The change looks good and is working as expected. PFA the updated patch after running pgindent. Thank you, Beena Emerson EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Make WAL segment size configurable at initdb time.
- fc49e24fa69a 11.0 landed
-
Perform only one ReadControlFile() during startup.
- 8356753c212a 11.0 landed
-
Introduce BYTES unit for GUCs.
- 6e7baa322773 11.0 landed
-
Remove useless duplicate inclusions of system header files.
- 9e3755ecb2d0 10.0 cited
-
Refactor other replication commands to use DestRemoteSimple.
- bbd8550bce14 10.0 landed
-
Add a SHOW command to the replication command language.
- d1ecd539477f 10.0 landed
-
Add a new DestReceiver for printing tuples without catalog access.
- a84069d93504 10.0 landed
-
Support fls().
- 4f658dc851a7 9.2.0 cited
-
Extend yesterday's patch making BLCKSZ and RELSEG_SIZE configurable to also
- cf9f6c8d8e9d 8.4.0 cited
-
Commit the reasonably uncontroversial parts of J.R. Nield's PITR patch, to
- c3c09be34b6b 8.0.0 cited
-
XLOG (also known as WAL -:)) Bootstrap/Startup/Shutdown.
- 47937403676d 7.1.1 cited
-
Transaction log manager core code.
- 30659d43eb73 7.1.1 cited