Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1miiwN-00088d-0a for pgsql-bugs@arkaria.postgresql.org; Thu, 04 Nov 2021 20:02:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1miiwL-0002CY-1T for pgsql-bugs@arkaria.postgresql.org; Thu, 04 Nov 2021 20:02:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1miiwK-0002Bv-OR for pgsql-bugs@lists.postgresql.org; Thu, 04 Nov 2021 20:02:24 +0000 Received: from mail-ua1-x935.google.com ([2607:f8b0:4864:20::935]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1miiwI-0008EF-1c for pgsql-bugs@lists.postgresql.org; Thu, 04 Nov 2021 20:02:24 +0000 Received: by mail-ua1-x935.google.com with SMTP id i6so13085548uae.6 for ; Thu, 04 Nov 2021 13:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Z1e5SuDtp3jQ3h2W8jaNaOZPhbwmWIj76oOXSAcmtcU=; b=ldFeLzVuVBAxv+9ZuA6SFvD+w+k9rxGUUrLd2zvpYy8XIi6XleNHi5abyv9f/PcJCY 94ZIdX5CfaXdoBOB3o8iCagY37ayaW0aKB8PaxwuV3mjvNUlZTqQnXzM3BNb4oWl5hR4 p/a3mlH4nHYw7CNIRGdfIzdGuHA7LcDjJNO2If//kuEG4zJLn1QDeci3LriBiKRtJ8t6 BKktI/GJA6QjPefse/56MmRfXrMe8sEAE+UyYKa/2z4ouj3XnY0qG2ycJZBpeNSJaLJD TP+HZH/4ao1NWIaVlSkoycpZ8/eX8z1DwK9IEEOnXW3i09Y7hKrOX1whAVKrwmEMtyA3 Lwnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Z1e5SuDtp3jQ3h2W8jaNaOZPhbwmWIj76oOXSAcmtcU=; b=GX7dS+N+NLrtzM/UJS6Yy/osfLHgHVGcpus8Y88L5hgbagvqlmHrqF0U+ScK5mgjGs RYJ2rihRsff6CSPa37yF6qZxQF2iQ/lVslsG0/Ay1XWA3WDU7hZYny/rvkkCHtCxOA6S QyREzdx2n/ErlYW742K5b1koLQ59ehkXYp/br7SYUHnN5aDjV0JgQtnmZSUesf9RKcGm NZ5dcJSXN6X6YpdLbCaJvmdQ7pPOkq+hV1QZaaw2fdc3I9PoYKe2tRx8I3ly21WFeBXB Zga5HynsUNpBxiUy/zZDix8P/C0yQ7gd+UCpFwXjI0zrJIR9pVFhRaFhkdFABET2+YuO TdPw== X-Gm-Message-State: AOAM533TEyC30BuqDXZFP4gkIuBFVU6koekujo/f8AXEobfMC0nZBzMg n2hYLNvRCzd3cNbb5J/dBe1zk0yuHVb9nwmrhR8= X-Google-Smtp-Source: ABdhPJyhkV9ZkWrYp4/zkNqh07USoB+pkXYl6W/zy8rWHbG1IbNioaljEsWnjkxsFNJv7mPxdU3qi83qc3JzoCaaIbQ= X-Received: by 2002:ab0:20b4:: with SMTP id y20mr49203096ual.128.1636056140118; Thu, 04 Nov 2021 13:02:20 -0700 (PDT) MIME-Version: 1.0 References: <17268-d2fb426e0895abd4@postgresql.org> In-Reply-To: From: Maxim Boguk Date: Thu, 4 Nov 2021 22:01:44 +0200 Message-ID: Subject: Re: BUG #17268: Possible corruption in toast index after reindex index concurrently To: Peter Geoghegan Cc: Alexey Ermakov , PostgreSQL mailing lists , Michael Paquier 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 On Thu, Nov 4, 2021 at 9:47 PM Maxim Boguk wrote: > > On Thu, Nov 4, 2021 at 8:18 PM Peter Geoghegan wrote: > > > > On Thu, Nov 4, 2021 at 11:08 AM Maxim Boguk wro= te: > > > select bt_index_check('pg_toast.pg_toast_2624976286_index', true); > > > DEBUG: verifying consistency of tree structure for index > > > "pg_toast_2624976286_index" > > > DEBUG: verifying level 3 (true root level) > > > DEBUG: verifying level 2 > > > DEBUG: verifying level 1 > > > DEBUG: verifying level 0 (leaf level) > > > DEBUG: leaf block 715360 of index "pg_toast_2624976286_index" has no > > > first data item > > > DEBUG: verifying that tuples from index "pg_toast_2624976286_index" > > > are present in "pg_toast_2624976286" > > > ERROR: heap tuple (59561917,1) from table "pg_toast_2624976286" lack= s > > > matching index tuple within index "pg_toast_2624976286_index" > > > HINT: Retrying verification using the function > > > bt_index_parent_check() might provide a more specific error. > > > > That's an unusually large TOAST table. It's at least ~454.42GiB, based > > on this error. Is the block number 59561917 near the end of the table? > > select pg_size_pretty(pg_relation_size('pg_toast.pg_toast_2624976286')); > pg_size_pretty > ---------------- > 473 GB > now... and yes during the time of error page 59561917 was very close > to the end of the table. > There was a high chance (but not 100%) that the corresponding main > table entry had been inserted during reindex CONCURRENTLY of the toast > index run. UPDATE: the problem base table entry which had erroneous toast data definitely had been created during the REINDEX run of toast idx. 2021-11-02 13:15:45.469 UTC 2379 postgres@*** from [local] [vxid:24/0 txid:0] [REINDEX] LOG: duration: 1719120.441 ms statement: REINDEX INDEX CONCURRENTLY pg_toast.pg_toast_2624976286_index and the problem entry had been created at 2021-11-02 13:04:22.192125 UTC. So there seems some subtle bug with indexing new toast data during REINDEX INDEX CONCURRENTLY of the toast index. --=20 Maxim Boguk Senior Postgresql DBA https://dataegret.com/ Phone RU: +7 985 433 0000 Phone UA: +380 99 143 0000 Phone AU: +61 45 218 5678 LinkedIn: http://www.linkedin.com/pub/maksym-boguk/80/b99/b1b Skype: maxim.boguk "=D0=94=D0=BE=D0=BA=D1=82=D0=BE=D1=80, =D0=B2=D1=8B =D0=BC=D0=BD=D0=B5 =D1= =81=D0=BE=D0=B2=D0=B5=D1=82=D0=BE=D0=B2=D0=B0=D0=BB=D0=B8 =D1=82=D0=B0=D0= =BA =D0=BD=D0=B5 =D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C, =D0=BD=D0=BE =D0=BF= =D0=BE=D1=87=D0=B5=D0=BC=D1=83 =D0=BC=D0=BD=D0=B5 =D0=BF=D0=BE-=D0=BF=D1=80= =D0=B5=D0=B6=D0=BD=D0=B5=D0=BC=D1=83 =D0=B1=D0=BE=D0=BB=D1=8C=D0=BD=D0=BE =D0=BA=D0=BE=D0=B3=D0=B4=D0=B0 =D1=8F = =D1=82=D0=B0=D0=BA =D0=B4=D0=B5=D0=BB=D0=B0=D1=8E =D0=B5=D1=89=D1=91 =D1=80= =D0=B0=D0=B7?"