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 1mjsWr-0003NR-Vy for pgsql-bugs@arkaria.postgresql.org; Mon, 08 Nov 2021 00:28:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mjsWp-0006L8-Kk for pgsql-bugs@arkaria.postgresql.org; Mon, 08 Nov 2021 00:28:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mjsWp-0006Kz-93 for pgsql-bugs@lists.postgresql.org; Mon, 08 Nov 2021 00:28:51 +0000 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mjsWm-0001Qf-QR for pgsql-bugs@lists.postgresql.org; Mon, 08 Nov 2021 00:28:50 +0000 Received: by mail-il1-x12f.google.com with SMTP id h2so15184482ili.11 for ; Sun, 07 Nov 2021 16:28:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SXsYO6nCCx4vJZUsr34HKNS8tkTGYYJ+b8vTdg5HZNQ=; b=xHyCqAkAbudnE+yFfcn1wcpoKqg6wnuOQIyVDALWkQX/VtBicut41Y5cq7kqNpHPNh GLY6gUDF/0A6zRYifnWxfrvNVBzeknbyL+jWdwY1M+zz8/ENylHAI+Zvg1o7aLV/Cspf jhyO971G+12mJB8kSS3tv0axJvxfa0Ab2j6I0LrSlzXrfJuGaOv8JtlcHGHUrS91p+gW 0wV4oCApQfpJlPdS508QNK9Cc7p3eWrtzClQOytk/wnsnkSrVKajOJYu/acdDZMtog3H Ymyqt/iIcmjuBrKxY3cDC0eiAJM2ltapMmqev9T12W/Ki4XZfWSazJqXt7eT9PVgGpNI alCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=SXsYO6nCCx4vJZUsr34HKNS8tkTGYYJ+b8vTdg5HZNQ=; b=nUdq07JH5pXo/JtbC29NmraAunQYhR3KBZIf29Mxuup7VA8yGqPpbUPBUIZniCHCKB urNBnOmKQSjx3dI/8iVvDvNIXD0+njH/wTxj/I4OHQ6qlKqoX6Ryb2Bg/nd91afRCxj2 f80MuvbozfcGsf43E9PRizFArZYRghQpFbgvh/2qGu6HE2gAddT2YtHG0/2Q5cA68mVi ura01VVnfv1gH/DpES4UI+3YGxVuWarxqONygaOzR7XYRvR96eQsWDyD+eApN1a/i8rK USn1As5z/ekdFv6PkNBsw4TJoP2SHD1eAEpdQLdk+w1sd/LjhX1V9QRI2BP9VvBMY0CF 8sAQ== X-Gm-Message-State: AOAM530bCZwe4okpZZRaASdJkG0PgAdEdkUr+cFhxDnY5/yknp5YZr/A ocxO71MMfIBKK6oXfoRJC1KLaQ== X-Google-Smtp-Source: ABdhPJwBG85rx0gKwF3bfXenSA/SLoIpDp8CNKRCStOKNyWU0uZknrmpW3LSUJX0SUr/1b+HyAxyUQ== X-Received: by 2002:a05:6e02:19cb:: with SMTP id r11mr23256894ill.151.1636331327843; Sun, 07 Nov 2021 16:28:47 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id w21sm1860941iov.43.2021.11.07.16.28.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Nov 2021 16:28:47 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id AB9A8800534; Sun, 7 Nov 2021 18:28:46 -0600 (CST) Date: Sun, 7 Nov 2021 18:28:46 -0600 From: Justin Pryzby To: Peter Geoghegan Cc: Andres Freund , Kamigishi Rei , Amit Kapila , Andrew Gierth , Alvaro Herrera , pgsql-bugs@lists.postgresql.org, Thomas Munro Subject: Re: BUG #17245: Index corruption involving deduplicated entries Message-ID: <20211108002846.GL17618@telsasoft.com> References: <20211030204246.d6zda3sa46bqpo5l@alap3.anarazel.de> <20211030221824.xhzfhwveam7ymqha@alap3.anarazel.de> <20211104220722.iyvpoyacqzvm2z5v@alap3.anarazel.de> <20211104231235.3jnopbdpubn3csy7@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I was going to ask if it's possible to look for corrupted indexes somehow, but already discovered two likely instances of this issue: $ /usr/pgsql-14/bin/pg_amcheck --relation ts.child.alarms_null_alarm_clear_time_idx btree index "ts.child.alarms_null_alarm_clear_time_idx": ERROR: posting list contains misplaced TID in index "alarms_null_alarm_clear_time_idx" DETAIL: Index tid=(26,10) posting list offset=88 page lsn=223E/92E3DA40. The index in one case is now 448 kB, in the other case is 632 kB, so I suspect they're due to this bug (for the 2nd one, a new index created from scratch with the same definition is 144 kB). I tried looking for duplicate TIDs like this (which I wrote to search every suspect table before I found the above issue) - I'm not sure this is right, though. | SELECT format('SELECT htid, COUNT(1), %L, %L, %L FROM bt_page_items(%L||''.''||%L,%s) WHERE htid IS NOT NULL AND tids IS NOT NULL GROUP BY 1 HAVING COUNT(1)>1 LIMIT 1', relname, blk, COUNT(1)OVER(), relnamespace::regnamespace, relname, blk ) FROM pg_class c JOIN pg_am a ON c.relam=a.oid AND a.amname='btree' , generate_series(1,pg_relation_size(c.oid)/8192 - 1)blk WHERE c.relkind='i' AND relpages<99 AND (relnamespace=to_regnamespace('child') AND relname~'null') ; But this doesn't find any issue in that index. If I'm not wrong, "duplicate TIDs" are just one likely symptom of the bug, but not its only consequence. I donno how the TIDs can get out of order, though? I thought you might like to know about another instance of this in the wild. I'll disable those indexes and leave them around for a bit in case there's any question about them. -- Justin