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.94.2) (envelope-from ) id 1uxmxj-000YXk-R4 for pgsql-general@arkaria.postgresql.org; Sun, 14 Sep 2025 13:40:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uxmxh-007fel-Od for pgsql-general@arkaria.postgresql.org; Sun, 14 Sep 2025 13:40:14 +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.94.2) (envelope-from ) id 1uxmxh-007fed-Ce for pgsql-general@lists.postgresql.org; Sun, 14 Sep 2025 13:40:14 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uxmxd-000lVz-3A for pgsql-general@lists.postgresql.org; Sun, 14 Sep 2025 13:40:13 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-45f2313dd86so19981765e9.2 for ; Sun, 14 Sep 2025 06:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1757857210; x=1758462010; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=rzvfjk5KvMfS7QLeuXi2bHNfYcE77FL9ribWeWzpE+w=; b=a7F0h4HxVMQGnawjCq2uf2K9ZRA0YwWbeSJ5MJpSZysRtqW19JcT9w8XtmoDcDCtZD J6XsOpGqPljK5M4TsB+8BbOg+CaSKG0ienK2hMh7tu2fGM5yxhVSvo3TrINWEadW6gWn Oz9hIp9pd7ASN+uUUBQf6WNTCaFUPR6LN/YjJR/KpcieYYZLfI2nNWrA7Izj8ye8zaeS vTcWGKF8Dn+N1oW+0UlSwVmklaWuXBRqej2xJIaCx+5rI/F0dTqdGzVk49B7M0E4WoqM fyC2ZPYuJISvOACa7w4UFbBBsFGfHUoZIeVwN6wn7+bXqjguKTedlgkefcqTLp/Qud5G 63qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757857210; x=1758462010; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rzvfjk5KvMfS7QLeuXi2bHNfYcE77FL9ribWeWzpE+w=; b=ZA4uPUg1nD1hzzOn+OXcqTP6/rpgCpNpLVx84jm3PN17RczIOR7xwyOpA3vtQpeHWd H8TAMiWu8LeHWN6E8F7TvGA7WJcx28VxDYbAGJU8HDmXhhZ+MYQ+6HFOCYiWvs2mYqWb ZWRmCG5aStNBvyfwLSK5s47yVeCn86rKAuXcA5AivkUnChvYVnAThhYs2JL3LyC2UUhc q03otaoP7iTRNTIapbRmCrCeQ4S51UAodz+b5qn2QbV9yRp+6cKnmxA/UdwlLF+r1fZP 1YbQvDM2FhjpmxSz/o0e7xWFnEACp//83XrjBWktslQZiiaFUmbHQ17XQE/1jeA0busR jruA== X-Forwarded-Encrypted: i=1; AJvYcCXQdJQeThibfJCmMnDEX/bBPp+t0aTuname5qFczzEP+JiKc/UlJGJATYbrgkNYTDzaVpxcsUoJdEYYl74l@lists.postgresql.org X-Gm-Message-State: AOJu0YzWYgALoIsvdF1YsQNAg9IRqUEtPdI8mzbSzK51m7UFi2k18CaU 7BcUNdmRVz/6eRJgP+hDoGo4Xfma+XlvWymhgre31mQjyVAxrNn4XaT4VU9aKOodZlU= X-Gm-Gg: ASbGncshlE33+mAcQQKvIyQSZBWq1JSmo4Fpr1GD/DCij3KvJmeUSpiAhAqfwQGsoc9 Ig8X1Mshoz2ugZ9+hT69bw8QrfW+Ye8BWvef8EtDP8UWqEVUF7xTcDNZYOkW5lW7PmzWYSXJrO+ j2QyG5F47cq2geJWglfLM135zPcWcxuOg44iC0UdI18Wn4HS0G8rGX3Q4h6P9yiRXauVG8YROJs buOezkiB60tQmQQC91eoVzTZ4yFhSanMmSTC4ufPRHTne5kMjS1lcVvJ2lqBtHOff4HkQbtuv57 Iqb3nw1TMZdCTDMC1S6tSjxdFWrUG+n5R+Y53QE8hPlzfrv85a9Ev/YAWPz8NNoSrJSYy3d6v3u thGy7H/l1bhhFAhbcuJgzj6HEw26xl6emP1sLwGE/qv1Fu6q3xH88vCyzPd97jX8= X-Google-Smtp-Source: AGHT+IHCCRMp4OfEXsdwpw4VYDu3uqLUqQkdSJS22iuWyGV/opCBFJ3sVfpxsfvyEPGsH402F8rWug== X-Received: by 2002:a05:600c:4ed1:b0:45f:280d:15ea with SMTP id 5b1f17b1804b1-45f280d1cc8mr38995585e9.26.1757857209884; Sun, 14 Sep 2025 06:40:09 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:255:30a:2403:9037:2d08:c2c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45e015784c3sm144527845e9.10.2025.09.14.06.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Sep 2025 06:40:09 -0700 (PDT) Message-ID: <696bc97940384f72eca0d410bc069061902e43c9.camel@cybertec.at> Subject: Re: Silent data corruption in PostgreSQL 17 - how to detect it proactively? From: Laurenz Albe To: Pawel Kudzia , pgsql-general@lists.postgresql.org Date: Sun, 14 Sep 2025 15:40:08 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 2025-09-14 at 14:47 +0200, Pawel Kudzia wrote: > On Sun, Sep 14, 2025 at 12:35=E2=80=AFPM Laurenz Albe wrote: > > On Sun, 2025-09-14 at 10:30 +0200, Pawel Kudzia wrote: > > > I've hit a silent data corruption for TOAST data - leading to some > > > infinite loop when accessing bytea column for very particular row. I > > > did not suffer data loss - data from streaming replica was fine, I've > > > used it to rebuild the main server. > > >=20 > > > I'm wondering if there's any proactive way of detecting that type of > > > an issue rather than discovering pile-up of SELECT queries leading to > > > CPU starvation or finding hanged backup jobs. > > >=20 > > > PostgreSQL's log does not have any error messages indicating data cor= ruption. > > >=20 > > > This server does not have checksums enabled, but - as I understand - > > > such checksums cannot be checked online anyway. So - how can I detect > > > similar corruption? > >=20 > > A proactive way of detecting TOAST corruption... how about > >=20 > > pg_dump -f /dev/null yourdatabase > >=20 > > If there is TOAST corruption, that should give you an error. >=20 > Thanks for your answer! pg_dump mydatabase ends with ~the same as the > SELECT statement. > It hangs leaving 'postgres: 17/main: postgres application_cache > [local] COPY' using 100% of single CPU core and no messages in PG's > logs. >=20 > I was curious if there's any other tool that can spot that type of > corruption and state it explicitly rather than guess it by monitoring > execution time. Data checksums would certainly be a step in the right direction. They are checked whenever the data are read from storage. There is no tool that will reliably detect all kinds of data corruption. Another tool ar your disposal are the functions from the amcheck contrib module (or the pg_amcheck executable that calls them). Yours, Laurenz Albe