postgresql/src/bin/pg_basebackup
Tom Lane 44cac93464 Avoid using potentially-under-aligned page buffers.
There's a project policy against using plain "char buf[BLCKSZ]" local
or static variables as page buffers; preferred style is to palloc or
malloc each buffer to ensure it is MAXALIGN'd.  However, that policy's
been ignored in an increasing number of places.  We've apparently got
away with it so far, probably because (a) relatively few people use
platforms on which misalignment causes core dumps and/or (b) the
variables chance to be sufficiently aligned anyway.  But this is not
something to rely on.  Moreover, even if we don't get a core dump,
we might be paying a lot of cycles for misaligned accesses.

To fix, invent new union types PGAlignedBlock and PGAlignedXLogBlock
that the compiler must allocate with sufficient alignment, and use
those in place of plain char arrays.

I used these types even for variables where there's no risk of a
misaligned access, since ensuring proper alignment should make
kernel data transfers faster.  I also changed some places where
we had been palloc'ing short-lived buffers, for coding style
uniformity and to save palloc/pfree overhead.

Since this seems to be a live portability hazard (despite the lack
of field reports), back-patch to all supported versions.

Patch by me; thanks to Michael Paquier for review.

Discussion: https://postgr.es/m/1535618100.1286.3.camel@credativ.de
2018-09-01 15:27:17 -04:00
..
po Translation updates 2018-06-25 12:37:18 +02:00
t perltidy run prior to branching 2018-06-30 12:28:55 -04:00
.gitignore Rename user-facing tools with "xlog" in the name to say "wal". 2017-02-09 16:23:46 -05:00
Makefile Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-04-03 16:26:05 -04:00
nls.mk Translation updates 2018-05-21 12:29:52 -04:00
pg_basebackup.c Add verbosity to pg_basebackup for sync 2018-07-29 07:53:11 +09:00
pg_receivewal.c Rework error messages around file handling 2018-07-18 08:01:23 +09:00
pg_recvlogical.c Make more consistent some error messages for file-related operations 2018-07-23 09:19:12 +09:00
receivelog.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
receivelog.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
streamutil.c Message wording and pluralization improvements 2018-05-17 23:05:27 -04:00
streamutil.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
walmethods.c Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
walmethods.h Update copyright for 2018 2018-01-02 23:30:12 -05:00