Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vdUrW-001LCE-17 for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Jan 2026 14:50:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vdUrV-00EYLi-0g for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Jan 2026 14:50:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vdUrU-00EYLY-2E for pgsql-hackers@lists.postgresql.org; Wed, 07 Jan 2026 14:50:13 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vdUrT-004jD8-32 for pgsql-hackers@lists.postgresql.org; Wed, 07 Jan 2026 14:50:12 +0000 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-650854c473fso1809942a12.1 for ; Wed, 07 Jan 2026 06:50:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767797409; x=1768402209; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:subject:mime-version:from:from:to:cc:subject:date :message-id:reply-to; bh=bwHm2UQ17BYbQU7jDv+5wdKtvwfXlnrpdg5tLW5+R3I=; b=eXCqFm+gWUal5Pk8/ZfCi4JKjE06l3zM6FN5sfIEtuwR7FsxS1raZHObYqgkpgrIZs /DwYgIYBylEAe/9VkhRmnbacKapYPcZuGOj49nNfHcc3wSPapLmVuRxndQjkmemq2Y2r piOH7UROr/tMgf2RgIXiLJWuwbJ9BHwa3LN+ZezH737mSAfPEmfNO3uIfrlBvXsVBwKz MHfNhVKZ5vdL4LbMorfyQ5kjaeMquQapJsCts4374dWcewZHuChZMrb4uDTxM4Fuo9kk 6E9f6H/iY9ySTfKHy4mF0wqEdfbqFNqa15SZe67KqAKMFbD34m35wp73mZiv2G85cHqc uPUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767797409; x=1768402209; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:subject:mime-version:from:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bwHm2UQ17BYbQU7jDv+5wdKtvwfXlnrpdg5tLW5+R3I=; b=LfUelsU3pz5AwJuiwYYl6edGnvnSWWgaDq99lr/ba4AKtmp0d4CJ+fKlYy54+/xScG 4jPGmoENypf/wAksTfeVlk12IdhfENDG0fYTySvsKk0Us397qJniI16BMw/n9E204WYX fFtEjzcbzfCCXA2W6bppYTxf02GUQMgIeRMmGbmF3xwj/1IcO+mXOOdVzqvdrBFa3DIw PKJ9ww2onXBELQG9JdaluDQWQJr8B5ODIi3oNvnXmODwBO8axjTO58INvSOcx/16qHQ3 eY6IvqZ20xrBFAbqUQkWj2X9XlntduUa7s6cDs+J7JcwMSv4QXEMXnagxR8rMTt17Zn6 RfDQ== X-Forwarded-Encrypted: i=1; AJvYcCVOWhJBUGddcIoFY+etIiQFYOH0TfHcMYLgEg3Zm2t0upnnLwpTkH2u4JCqd4mDQL9qz4J+JPCEQZZ7+iaQ@lists.postgresql.org X-Gm-Message-State: AOJu0Yx7J8RXtmHJR3dxApMT7nsAmNa7p2S92IJblzOnDQGDMdOSvPvd /5YeoD78OsP4M+gq06tTVqSb4j4hIRePdc99ZJnm0BpL6I9IJfoCig6y X-Gm-Gg: AY/fxX5n66k2O9gE6FHAPwduQLZ5nvflV8g1zyHp6Hs0IrYs4xa5g9YpO/rs6TAym/x gYEPGoYjvV32d+XjwtlW975kpBDUAO90vN8BK80dQlTZW4gYJazKhQWfXU08hly+sjVBYBCu/EM veP7b9R9JlZToiuqmXxokQ+ooz+cQHwLMUvrPAPu4McZ/1J/HxOmuQoFhWiAqJ2loF4rLRtMhB0 2XH9zJN/Pn0WNlGSFCjUuiZu4ZueUaRcq3AN7wu97rf9Pyqx7tNwfwNG7wJhFSZcRuWlDCU9T7X h7AjZtD2yYSkkmZgxOIPwphWFgAF5ijDqy2jOG8L7xlUnZLuQ0Bn3Ae99PLiotEZIe6Iid0k4WL LTL8BeaE4/tSLkeqp9+/IoNgYV9m08b7dCnUM2iCydWYiz8wbYM9mlPL4h9kkR/lFt71avfh0gO IsGKOEHKAK0Rt11Hggs81KbvmeogelfD/xgAHADTJGip3teA== X-Google-Smtp-Source: AGHT+IFiq9EVt7NzEAIINIKR9zp/TH3Jx0yAV2DTev/WEjRg2cJD2F7Op1JvsQo2TMUOnqmdtEQSsg== X-Received: by 2002:a05:6402:5691:b0:650:5cbe:55d8 with SMTP id 4fb4d7f45d1cf-6507b5ab4ccmr4879275a12.0.1767797408292; Wed, 07 Jan 2026 06:50:08 -0800 (PST) Received: from smtpclient.apple ([2a02:a31a:a49d:1500:c8e8:2e56:389e:e79b]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6507be64efasm4683213a12.21.2026.01.07.06.50.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jan 2026 06:50:07 -0800 (PST) From: Oleg Tkachenko X-Google-Original-From: Oleg Tkachenko Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.300.41.1.7\)) Subject: Re: [BUG] [PATCH] pg_basebackup produces wrong incremental files after relation truncation in segmented tables In-Reply-To: Date: Wed, 7 Jan 2026 15:49:56 +0100 Cc: Amul Sul , pgsql-hackers@lists.postgresql.org, Stanislav Bashkyrtsev Content-Transfer-Encoding: quoted-printable Message-Id: <6897DAF7-B699-41BF-A6FB-B818FCFFD585@gmail.com> References: <00FEFC88-EA1D-4271-B38F-EB741733A84A@gmail.com> <22474984-C4CD-4300-A84E-C1CA58F61CDA@gmail.com> <08EA8874-0114-4E5C-A794-EB40C971EE7C@gmail.com> To: Robert Haas X-Mailer: Apple Mail (2.3864.300.41.1.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Robert, I checked the VM fork file and found that its incremental version has a = wrong block number in the header: ``` xxd -l 12 INCREMENTAL.16384_vm 0d1f aed3 0100 0000 0000 0200 <--- 131072 blocks (1 GB) ^^^^ ^^^^=20 ``` This value can only come from the WAL summaries, so I checked them too. One of the summary files contains: ``` TS 1663, DB 5, REL 16384, FORK main: limit 131073 TS 1663, DB 5, REL 16384, FORK vm: limit 131073 TS 1663, DB 5, REL 16384, FORK vm: block 4 ``` Both forks have the same limit, which looks wrong.=20 So I checked the WAL files to see what really happened with the VM fork. I did not find any =E2=80=9Ctruncate" records for the VM file. I only found this record for the main fork=20 (actually, the fork isn=E2=80=99t mentioned at all): ``` rmgr: Storage len (rec/tot): 46/46, tx: 759, lsn: 0/4600D318, prev 0/4600B2C8, desc: TRUNCATE base/5/16384 to 131073 blocks flags 7 ``` This suggests that the WAL summarizer may be mixing up information = between relation forks. I also noticed this comment in basebackup_incremental.c: ``` /* * The free-space map fork is not properly WAL-logged, so we need to * backup the entire file every time. */ if (forknum =3D=3D FSM_FORKNUM) return BACK_UP_FILE_FULLY; ``` Maybe we should treat the VM fork the same way and always back it up = fully? Another option is to fix the summarizer so it handles forks correctly. Best regards, Oleg > On Jan 5, 2026, at 17:05, Robert Haas wrote: >=20 > On Thu, Dec 18, 2025 at 12:24=E2=80=AFPM Oleg Tkachenko = wrote: >> Here is a refactored test. >>=20 >> Now, it creates data depending on the relation block size, so it = works even if the segment size is not standard. I tested it locally with = segment_size_blocks =3D 6, and it works correctly. >>=20 >> I would be happy to hear your comments or suggestions. >=20 > Hi Oleg, >=20 > I have been mostly on vacation since you sent this email, but here I > am back again. I tried running this on CI with and without the actual > code fix, and was pleased to see the CI failed on this test without > the code fix and passed with it. But then I noticed that you hadn't > updated meson.build in src/bin/pg_basebackup for the new test, which > means that the test was only running in configure/make builds and not > in meson/ninja builds. When I fixed that, things didn't look so good. > The test then fails: >=20 > pg_combinebackup: reconstructing > = "/tmp/cirrus-ci-build/build/testrun/pg_basebackup/050_incremental_backup_t= runcation_block/data/t_050_incremental_backup_truncation_block_node2_data/= pgdata/base/5/16384.1" > (1 blocks, checksum CRC32C) > pg_combinebackup: reconstruction plan: > = 0:/tmp/cirrus-ci-build/build/testrun/pg_basebackup/050_incremental_backup_= truncation_block/data/t_050_incremental_backup_truncation_block_primary_da= ta/backup/full/base/5/16384.1@0 > pg_combinebackup: read 1 blocks from > = "/tmp/cirrus-ci-build/build/testrun/pg_basebackup/050_incremental_backup_t= runcation_block/data/t_050_incremental_backup_truncation_block_primary_dat= a/backup/full/base/5/16384.1" > pg_combinebackup: reconstructing > = "/tmp/cirrus-ci-build/build/testrun/pg_basebackup/050_incremental_backup_t= runcation_block/data/t_050_incremental_backup_truncation_block_node2_data/= pgdata/base/5/16384_vm" > (131072 blocks, checksum CRC32C) > pg_combinebackup: reconstruction plan: > = 0-3:/tmp/cirrus-ci-build/build/testrun/pg_basebackup/050_incremental_backu= p_truncation_block/data/t_050_incremental_backup_truncation_block_primary_= data/backup/full/base/5/16384_vm@24576 > = 4:/tmp/cirrus-ci-build/build/testrun/pg_basebackup/050_incremental_backup_= truncation_block/data/t_050_incremental_backup_truncation_block_primary_da= ta/backup/incr/base/5/INCREMENTAL.16384_vm@8192 > 5-131071:zero > pg_combinebackup: error: could not write file > = "/tmp/cirrus-ci-build/build/testrun/pg_basebackup/050_incremental_backup_t= runcation_block/data/t_050_incremental_backup_truncation_block_node2_data/= pgdata/base/5/16384_vm": > No space left on device >=20 > I'm not sure what's going on here exactly, but it seems bad. The > output implies that 16384_vm is a full 1GB in size, which doesn't > really make any sense to me at all, but the same thing also happens > when I run the test locally. The VM fork is normally quite small > compared to the data, and here the data is only one block over 1GB, so > I'd expect the VM fork to be just a few blocks. Are we somehow > confusing the length of the VM fork with the length of the main fork? >=20 > A couple of stylistic notes: All of the existing incremental backup > tests are in src/bin/pg_combinebackup/t. I suggest putting this one > there too. Normally, our TAP test names are all lower-case, so do the > same here. Try to format the test file so that things fit within 80 > columns, by breaking comments and Perl statements at appropriate > points. Consider running src/tools/pgindent/pgperltidy over the script > to check that the way you've broken the Perl statements won't get > reindented. >=20 > --=20 > Robert Haas > EDB: http://www.enterprisedb.com