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 1wvxRu-001eKq-18 for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Aug 2026 13:32:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wvxRs-00AcJ5-0s for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Aug 2026 13:32:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wvxRr-00AcIx-2r for pgsql-hackers@lists.postgresql.org; Mon, 17 Aug 2026 13:32:21 +0000 Received: from mail1.dalibo.net ([51.159.93.128] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wvxRq-00000001DmB-1Whn for pgsql-hackers@lists.postgresql.org; Mon, 17 Aug 2026 13:32:20 +0000 Received: from karst (82-65-23-130.subs.proxad.net [82.65.23.130]) by mail.dalibo.com (Postfix) with ESMTPSA id C9DF6278A5 for ; Mon, 17 Aug 2026 15:32:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalibo.com; s=a; t=1786973537; bh=mkupImsWXcxc8qBsieGdkktLiw4RzxmPTC2ToACwEv4=; h=Date:From:To:Subject:In-Reply-To:References:From; b=Uq6bldzbrabNgpG24Aeifr38RPpGFBogWBFrfQKyoTDTqOTrsvDYQ1D30WvF5ekF7 NrWemUxFdv3b0qFMjSvwdji3qwcXadDcXusJWiC8wPIvBGLKzL5VA2MSHIQEaHUUjJ fzQ388ydTM+a8UbsfVvRujhDNfKxsli6ZObcv7xY= Date: Mon, 17 Aug 2026 15:32:14 +0200 From: Jehan-Guillaume de Rorthais To: PostgreSQL Hackers Subject: Re: Possible Visibility Map corruption in supported branches? Message-ID: <20260817153214.3ecb435f@karst> In-Reply-To: <20260724001859.7f168328@karst> References: <20260626121955.1431eaca@karst> <20260724001859.7f168328@karst> Organization: Dalibo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi All, Hi Andres, First, customer told us the backup repository snapshot we were working on w= as lost. We only have the WAL files and the VM files left=E2=80=A6 He has been able to keep the repo snapshot from June 10th, holding data and archives down to May 31st. But we might not be able to keep it for a long t= ime=E2=80=A6 1. Why the error appeared June 4th As I wrote upthread, the error about missing "pg_xact/0D44" appeared duri= ng the nightly vacuum of June 4th 2AM. The pg_control files allows to explain what happened: 20260531-210002F: Latest checkpoint's oldestXID: 34981= 65236 20260531-210002F_20260601-210002I: Latest checkpoint's oldestXID: 34981= 65236 20260531-210002F_20260602-210001I: Latest checkpoint's oldestXID: 34981= 65236 20260531-210002F_20260603-210001I: Latest checkpoint's oldestXID: 35969= 46949 20260531-210002F_20260604-210002I: Latest checkpoint's oldestXID: 35969= 46949 20260531-210002F_20260605-210001I: Latest checkpoint's oldestXID: 35969= 46949 20260531-210002F_20260606-210002I: Latest checkpoint's oldestXID: 35969= 46949 The horizon jump from 3,498,165,236 to 3,596,946,949 between June 2nd and 3rd, removing all segments from 0D08 =C3=A0 0D65, including 0D44. An old = rows might have been frozen somewhere in the cluster, this doesn't seem unexpected. The corruption probably occurred way before this time. We cou= ld check the WAL between 2nd and 3rd of June, as long as the snapshot is kep= t, if someone think of something fishy about this oldestXID jump. 2. WAL analysis between May 13th to May 15th I've been able to collect more WALs covering the INSERTs/ABORT in these blocks and what happened after. The nightly vacuum of May 14th 2AM is interesting. I checked what happene= d to 500 consecutive blocks before and 500 consecutive blocks after the corrup= tion zone (3,691,936 -> 3,694,482). Blocks outside of the corruption zone has = been vacuumed and visibility bits sets, eg for one of them: LSN Num Record type Archiving d= ate D171/7E94D590 1 INSERT+INIT May 13th 19= h02 D171/7E94EBC0 to D171/7E954568 26 INSERT May 13th 19= h02 D171/7E94EB68 to D171/7E9546F0 27 ABORT May 13th 19= h02 D1A5/14E22C58 1 CLEAN remxid 0 May 14th 02= h11 D1A6/6421D380 1 CLEAN remxid 0 FPW May 14th 02= h14 D1A6/6421D440 1 VISIBLE cutoff xid 0 May 14th 02= h14 Looking at bad blocks they all have been skipped by the vacuum. There is = ONLY the INSERT+INIT/INSERT/ABORT records for them. Here's the sum up of the xlog records including the insert batch + nightly vacuum, for the 500 consecutive blocks before and after the corruption zo= ne: # 500 before (3,691,436 to 3,691,935): kind =E2=94=82 count --------------+------- INSERT+INIT =E2=94=82 500 INSERT =E2=94=82 12983 ABORT =E2=94=82 13483 FPI_FOR_HINT =E2=94=82 504 CLEAN =E2=94=82 1000 VISIBLE =E2=94=82 500 # 500 after (3,694,483 to 3,694,982): kind =E2=94=82 count --------------+------- INSERT =E2=94=82 12981 FPI_FOR_HINT =E2=94=82 515 ABORT =E2=94=82 13481 CLEAN =E2=94=82 1000 VISIBLE =E2=94=82 500 INSERT+INIT =E2=94=82 500 For each block, there's one INSERT+INIT, about 27 INSERT and as many ABORT rollbacking all of them. Each block has two CLEAN record and one VISIBLE. Sum up of the same period for the 2547 consecutive corrupted blocks: kind =E2=94=82 count --------------+------- INSERT | 65905 INSERT+INIT =E2=94=82 2547 ABORT =E2=94=82 68452 FPI_FOR_HINT =E2=94=82 50 Well, no CLEAN, no VISIBLE there. I don't understand what would keep the vacuum away specifically for these blocks and not the other surrounding o= nes=E2=80=A6 So considering your question: > - Are there any vacuum related WAL records for the affected heap blocks= ? If > e.g. the relevant rows were removed as part of a VACUUM, this would l= ikely > be evidence of the write somehow having gotten lost. It doesn't seems a vacuum record has been lost. We don't have the vacuum activity from May 15th though. Considering: =20 > One interesting thing to look at is whether there are WAL records for= the > affected page with a later LSN than what you saw when the first vacuum > failed. No activity past the May 13th ~19h02 batch on these blocks. Note that I o= nly checked between May 13th 18h22 and May 15th 02h05. > I'd check a few of the base backups for > a) the size of the heap relation Unfortunately, this will not be possible. > b) the contents of one of the affected blocks Not possible either. Note that I still have the xlog records writting the= se blocks and they are similar to what we observed and extracted from the ta= ble mid-june. 3. Tail of the heap? As written in intro, unfortunately we don't have the heap files anymore. However, I've been able to find six blocks located after the corruption z= one with only INSERT records and no INSERT+INIT. One of them (3,787,952) is in the same heap segment. So I suppose the corruption zone was not the tail = of the heap, neither the tail of a segment, despite the large amount of INSERT+INIT found. 4. Write activity during maintenance It seems the INSERT batch was still running during the vacuum of the table (May 14th, between 02h00 and 02h15), with 167778 records inserted during = this maintenance (according to LSN). I didn't dig this yet. 5. Storage setup & versions The server is a VM managed by VMWare. Each ESX access 4TB datastores in a= SAN using Hitachi hardware as storage layer, using multipath (eight paths per LUN). VMs are using 1TB VMDKs created in these datastores. LVM is used in= side the VMs. OS: RHEL8, May 12th kernel version was kernel-4.18.0-553.111.1.el8_10.x86= _64. No known failures on the SAN or ESXs around May 12th. 6. pg_reorg or pg_repack Using such tools is prohibited in production without asking internal DBA = team first. The DBA team confirmed with developers they never used them, neith= er in scripts or manualy, but some are still on holidays. However, it seems highly improbable these tools were used in production. 7. Other There's still no TRUNCATE on this relation and none of the corrupted bloc= ks has more than one +INIT xlog record during the batch and VACUUM maintenan= ce. I keep digging 4. Regards,