pgbackrest.git / summary / log / commit / refs

commit    253dbc3f03e5581c98bb97b252dc77b8defd3693
Author:   David Steele <david@pgbackrest.org>
Commit:   GitHub <noreply@github.com>
Date:     Thu Jun 25 08:52:17 2026 +0000

    Bundle backup files in order rather than scanning for a better fit.
    
    Previously a file that would push a bundle over repo-bundle-size was skipped in the hope that a smaller file later in the queue would fit, which kept bundles under the target size at the cost of additional file unpacks.
    
    Now files are added to the bundle in queue order and the bundle is closed once it reaches repo-bundle-size. As a result a bundle may exceed the target size by up to repo-bundle-limit, i.e. the size of the file that crosses the threshold, which is now noted in the help for repo-bundle-size.
    
    In addition to the immediate benefits, this is important for a future commit where preserving bundle order from the prior backup is important.


doc/xml/release/2020s/2026/2.59.0.xml | 11 +++++++++++ src/build/help/help.xml | 2 +- src/command/backup/backup.c | 7 ------- test/src/module/command/backupTest.c | 18 +++++++++--------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/doc/xml/release/2020s/2026/2.59.0.xml b/doc/xml/release/2020s/2026/2.59.0.xml index 2c0a7abe3..d9bd25869 100644 --- a/doc/xml/release/2020s/2026/2.59.0.xml +++ b/doc/xml/release/2020s/2026/2.59.0.xml @@ -121,6 +121,17 @@ <p>Improve seek performance during block incremental delta restore.</p> </release-item> + <release-item> + <github-pull-request id="2794"/> + + <release-item-contributor-list> + <release-item-contributor id="david.steele"/> + <release-item-reviewer id="stefan.fercot"/> + </release-item-contributor-list> + + <p>Bundle backup files in order rather than scanning for a better fit.</p> + </release-item> + <release-item> <github-issue id="2789"/> <github-pull-request id="2790"/> diff --git a/src/build/help/help.xml b/src/build/help/help.xml index d8e96f870..3b80d031d 100644 --- a/src/build/help/help.xml +++ b/src/build/help/help.xml @@ -679,7 +679,7 @@ <summary>Target size for file bundles.</summary> <text> - <p>Defines the total size of files that will be added to a single bundle. Most bundles will be smaller than this size but it is possible that some will be slightly larger, so do not set this option to the maximum size that your file system allows.</p> + <p>Defines the target size for files that will be added to a single bundle. The uncompressed bundle size may be as large as <br-option>repo-bundle-size</br-option> + <br-option>repo-bundle-limit</br-option>, so do not set this option to the maximum size that your file system allows.</p> <p>In general, it is not a good idea to set this option too high because retries will need to redo the entire bundle.</p> </text> diff --git a/src/command/backup/backup.c b/src/command/backup/backup.c index 728852d76..61f8a91c1 100644 --- a/src/command/backup/backup.c +++ b/src/command/backup/backup.c @@ -1958,13 +1958,6 @@ backupJobCallback(void *const data, const unsigned int clientIdx) { const ManifestFile file = manifestFileUnpack(jobData->manifest, *(ManifestFilePack **)lstGet(queue, fileIdx)); - // Continue if the next file would make the bundle too large. There may be a smaller one that will fit. - if (fileTotal > 0 && fileSize + file.size >= jobData->bundleSize) - { - fileIdx++; - continue; - } - // Is this file a block incremental? const bool blockIncr = jobData->blockIncr && file.blockIncrSize > 0; diff --git a/test/src/module/command/backupTest.c b/test/src/module/command/backupTest.c index 817e3cb62..9fa83dc89 100644 --- a/test/src/module/command/backupTest.c +++ b/test/src/module/command/backupTest.c @@ -3284,10 +3284,10 @@ testRun(void) " 8192\n" "P01 DETAIL: backup file " TEST_PATH "/pg1/stuff.conf (bundle 1/0, 12B, [PCT]) checksum [SHA1]\n" "P01 DETAIL: backup file " TEST_PATH "/pg1/postgresql.auto.conf (bundle 1/32, 12B, [PCT]) checksum [SHA1]\n" - "P01 DETAIL: backup file " TEST_PATH "/pg1/postgresql.conf (bundle 1/64, 11B, [PCT]) checksum [SHA1]\n" - "P01 DETAIL: backup file " TEST_PATH "/pg1/PG_VERSION (bundle 1/95, 2B, [PCT]) checksum [SHA1]\n" - "P01 DETAIL: backup file " TEST_PATH "/pg1/bigish.dat (bundle 2/0, 8KB, [PCT]) checksum [SHA1]\n" - "P01 DETAIL: backup file " TEST_PATH "/pg1/global/pg_control (bundle 3/0, 8KB, [PCT]) checksum [SHA1]\n" + "P01 DETAIL: backup file " TEST_PATH "/pg1/bigish.dat (bundle 1/64, 8KB, [PCT]) checksum [SHA1]\n" + "P01 DETAIL: backup file " TEST_PATH "/pg1/postgresql.conf (bundle 2/0, 11B, [PCT]) checksum [SHA1]\n" + "P01 DETAIL: backup file " TEST_PATH "/pg1/PG_VERSION (bundle 2/31, 2B, [PCT]) checksum [SHA1]\n" + "P01 DETAIL: backup file " TEST_PATH "/pg1/global/pg_control (bundle 2/53, 8KB, [PCT]) checksum [SHA1]\n" "P00 INFO: execute backup stop and wait for all WAL segments to archive\n" "P00 INFO: backup stop archive = 0000000105DB8EB000000001, lsn = 5db8eb0/180000\n" "P00 DETAIL: wrote 'backup_label' file returned from backup stop function\n" @@ -3301,12 +3301,12 @@ testRun(void) TEST_RESULT_STR_Z( testBackupValidateP(storageRepo(), STRDEF(STORAGE_REPO_BACKUP "/latest")), ".> {d=20191030-014640F}\n" - "bundle/1/pg_data/PG_VERSION {s=2, ts=-200000}\n" + "bundle/1/pg_data/bigish.dat {s=8191, ts=-72399999}\n" "bundle/1/pg_data/postgresql.auto.conf {s=12, ts=-72400000}\n" - "bundle/1/pg_data/postgresql.conf {s=11, ts=-2400000}\n" "bundle/1/pg_data/stuff.conf {s=12, ts=-72400000}\n" - "bundle/2/pg_data/bigish.dat {s=8191, ts=-72399999}\n" - "bundle/3/pg_data/global/pg_control {s=8192}\n" + "bundle/2/pg_data/PG_VERSION {s=2, ts=-200000}\n" + "bundle/2/pg_data/global/pg_control {s=8192}\n" + "bundle/2/pg_data/postgresql.conf {s=11, ts=-2400000}\n" "pg_data/backup_label.gz {s=17, ts=+2}\n" "pg_data/base/1/1.gz {s=8207, ckp=t}\n" "pg_data/base/1/2.gz {s=24576, ckp=t}\n" @@ -3381,7 +3381,7 @@ testRun(void) ".> {d=20191030-014640F_20191101-092000D}\n" "bundle/1/pg_data/global/pg_control {s=8192}\n" "pg_data/backup_label.gz {s=17, ts=+2}\n" - "20191030-014640F/bundle/1/pg_data/PG_VERSION {s=2}\n" + "20191030-014640F/bundle/2/pg_data/PG_VERSION {s=2}\n" "--------\n" "[backup:target]\n" "pg_data={\"path\":\"" TEST_PATH "/pg1\",\"type\":\"path\"}\n", [parent: 23e966cd8f17]