postgresql/src/backend
Tomas Vondra 10e3226ba1 Align blocks in incremental backups to BLCKSZ
Align blocks stored in incremental files to BLCKSZ, so that the
incremental backups work well with CoW filesystems.

The header of the incremental file is padded with \0 to a multiple of
BLCKSZ, so that the block data (also BLCKSZ) is aligned to BLCKSZ. The
padding is added only to files containing block data, so files with just
the header remain small. This adds a bit of extra space, but as the
number of blocks increases the overhead gets negligible very quickly.
And as the padding is \0 bytes, it does compress extremely well.

The alignment is important for CoW filesystems that usually require the
blocks to be aligned to filesystem page size for features like block
sharing, deduplication etc. to work well. With the variable sized header
the blocks in the increments were not aligned at all, negating the
benefits of the CoW filesystems.

This matters even for non-CoW filesystems, for example when placed on a
RAID array. If the block is not aligned, it may easily span multiple
devices, causing read and write amplification.

It might be better to align the blocks to the filesystem page, not
BLCKSZ, but we have no good way to determine that. Even if we determine
the page size at the time of taking the backup, the backup may move. For
now the BLCKSZ seems sufficient - the filesystem page is usually 4K, so
the default BLCKSZ (8K by default) is aligned to that.

Author: Tomas Vondra
Reviewed-by: Robert Haas, Jakub Wartak
Discussion: https://postgr.es/m/3024283a-7491-4240-80d0-421575f6bb23%40enterprisedb.com
2024-04-05 16:30:01 +02:00
..
access Operate XLogCtl->log{Write,Flush}Result with atomics 2024-04-05 16:14:39 +02:00
archive Add built-in ERROR handling for archive callbacks. 2024-04-02 22:28:11 -05:00
backup Align blocks in incremental backups to BLCKSZ 2024-04-05 16:30:01 +02:00
bootstrap
catalog CREATE INDEX: do not update stats during binary upgrade. 2024-04-03 16:12:45 -07:00
commands Add basic JSON_TABLE() functionality 2024-04-04 20:20:15 +09:00
executor Add basic JSON_TABLE() functionality 2024-04-04 20:20:15 +09:00
foreign
jit
lib Use the pairing heap instead of a flat array for LSN replay waiters 2024-04-03 18:15:41 +03:00
libpq
main
nodes Add basic JSON_TABLE() functionality 2024-04-04 20:20:15 +09:00
optimizer Don't adjust ressortgroupref in generate_setop_child_grouplist() 2024-04-03 15:39:29 +13:00
parser Add missing initialization in transformJsonFuncExpr() 2024-04-04 22:01:13 +09:00
partitioning
po
port
postmaster Add built-in ERROR handling for archive callbacks. 2024-04-02 22:28:11 -05:00
regex
replication Allow synced slots to have their inactive_since. 2024-04-05 09:48:49 +05:30
rewrite
snowball
statistics
storage Combine freezing and pruning steps in VACUUM 2024-04-03 19:32:28 +03:00
tcop Invent SERIALIZE option for EXPLAIN. 2024-04-03 17:41:57 -04:00
tsearch
utils Add "ABI_compatibility" regions to wait_event_names.txt 2024-04-05 08:56:52 +09:00
.gitignore
common.mk
Makefile
meson.build
nls.mk