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 1mlubS-0007xa-8K for pgsql-bugs@arkaria.postgresql.org; Sat, 13 Nov 2021 15:06:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mlubP-000785-Dj for pgsql-bugs@arkaria.postgresql.org; Sat, 13 Nov 2021 15:05:59 +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 <9erthalion6@gmail.com>) id 1mlubP-00077w-3h for pgsql-bugs@lists.postgresql.org; Sat, 13 Nov 2021 15:05:59 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1mlubM-0007po-SN for pgsql-bugs@lists.postgresql.org; Sat, 13 Nov 2021 15:05:58 +0000 Received: by mail-wm1-x335.google.com with SMTP id p18so788846wmq.5 for ; Sat, 13 Nov 2021 07:05:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GRDItVL7Vwe7aiFW4H2+Vp3SxC9cnLn0bDPxcCioQXE=; b=ZjZZTgwro8P1wh7oq9y4n+ZyBXHTAqQtMrtSvLDvvAMWLB+zhuvncsqTYcZE5OA21y 636JW6MmDODKu78jZk+lXHpVbUeONm3zkI9QgTNKe/ZBkmysb8tYc+ZXbOOvW8eSQ6oG yfz0cqedNIMdy8N812RdQUhQTx13D0WaWjEVSXJ08iKC81qMgxrTkk0u23vE7lVnJmdB mAAsLU5bhT8LVGOpnoo0xe51EelXUu/copTF3XyXLRQUViusLmPq2yABUrqVXYv5Aeb5 pTTWvXnBOYZz+E4SV1ebp/tulbHgn2lUuEWaihfWmH7wFisKpLR50S//GijBLo2m5Omo dbYw== 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; bh=GRDItVL7Vwe7aiFW4H2+Vp3SxC9cnLn0bDPxcCioQXE=; b=OmbgDS+AIbxIZ8LnAsWB6IuMPV77ottDGe4ybkihQNOK3XWhbRPXMEJhmLh5KdeRWi wk8wiQemtqkrUGF7PunoC97QHbKExUKteIHz7/9hKRsUyMT3fIXS62zS4RO63Mhnguz8 iNnGP64BS/PjfmrXxxBIWsJdmfeJVpqsrgZJvsMlNHF6Mz+2cAzcmCjLMu3EYpO4sex7 4x7Pr1BNBz3mGQeKUq3kz7mqoF3R9YUsdo0g2FukauXqIL/YNblio7hCoWjBTZ9Tai2C 4Tq5S+OJYppHZlorx+Nv9cYBDPCMw9ERr9ijGanEG/UOtA6TiM4y9kC8QBMot+TkstpL mGnQ== X-Gm-Message-State: AOAM533TgWasSekUWM3KNoOL+rhGUtSnDn/23uHSD2Di+W4ACB+X+cbW s4m6HFNVHsHMx2VtXPdzGPk= X-Google-Smtp-Source: ABdhPJyGBkPcmbBwWhwNAfECQ7yJNDC7EOEHT8Nb+YK0hXdsRyPgfxCFPMYxgb+kXmkUhTulpU5nng== X-Received: by 2002:a7b:cb56:: with SMTP id v22mr42509565wmj.77.1636815955641; Sat, 13 Nov 2021 07:05:55 -0800 (PST) Received: from localhost (dslb-178-012-041-031.178.012.pools.vodafone-ip.de. [178.12.41.31]) by smtp.gmail.com with ESMTPSA id o8sm8447985wrm.67.2021.11.13.07.05.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Nov 2021 07:05:55 -0800 (PST) Date: Sat, 13 Nov 2021 16:06:40 +0100 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Peter Geoghegan Cc: Andres Freund , Alexander Lakhin , Matthias van de Meent , PostgreSQL mailing lists Subject: Re: BUG #17255: Server crashes in index_delete_sort_cmp() due to race condition with vacuum Message-ID: <20211113150640.vk5zhjangylufxaa@localhost> References: <20211111030821.2xxl75qfkynaga4j@alap3.anarazel.de> <20211112222919.e7fkfpbpcoje6hsj@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Fri, Nov 12, 2021 at 02:46:22PM -0800, Peter Geoghegan wrote: > On Fri, Nov 12, 2021 at 2:29 PM Andres Freund wrote: > > > Naturally, I also went through the exercise of trying to find a > > > counterexample, where pruning doesn't see a disconnected tuple as DEAD > > > in its HTSV. I could not get the assertion to fail with Alexander's > > > test case, nor with make check-world. > > > > I don't think that provides a meaningful coverage. Alexander's test has a > > quite limited set operations (which e.g. doesn't include an subxacts), and our > > own tests around subtransactions, and particularly concurrent subtransaction > > heavy work, is quite, uh, minimal. > > It's a start. > > We need to be pragmatic here. There is some uncertainty about what > HTSV might say about a disconnected tuple in the absence of > corruption, or there is a risk of a new problem like that coming up in > the future -- let's work within those confines, then. What do you want > to do about that? There aren't that many choices, since, to repeat, > the tuple is "morally" DEAD no matter what. Even with corruption, even > without corruption in the presence of some unanticipated corner case > with HTSV -- this is fundamental. I've got curious if modifying the Alexander's test case could reveal something interesting, and sprinkled it with savepoints and rollbacks. Almost immediately a new problem has manifested itself, although the crash has nothing to do with the disconnected tuples as far as I can tell -- still probably worth mentioning. In this case vacuum invoked lazy_scan_prune, and during the first scan one of the chains had a HEAPTUPLE_DEAD at the third position. The processing flow fell through to heap_prune_record_prunable and crashed on an assert with an InvalidTransactionId: #3 0x000055a2b260d1f9 in heap_prune_record_prunable (prstate=0x7ffd0c0ecdf0, xid=0) at pruneheap.c:872 #4 0x000055a2b260ca72 in heap_prune_chain (buffer=2117, rootoffnum=150, prstate=0x7ffd0c0ecdf0) at pruneheap.c:695 #5 0x000055a2b260bcd6 in heap_page_prune (relation=0x7fb98e217e20, buffer=2117, vistest=0x55a2b31d2d60 , old_snap_xmin=0, old_snap_ts=0, report_stats=false, off_loc=0x55a2b3e6a0cc) at pruneheap.c:288 #6 0x000055a2b261309c in lazy_scan_prune (vacrel=0x55a2b3e6a060, buf=2117, blkno=192, page=0x7fb97856bf80 "", vistest=0x55a2b31d2d60 , prunestate=0x7ffd0c0ee9d0) at vacuumlazy.c:1739 Applying heap_prune_record_prunable only if TransactionIdIsNormal seems to help. The original implementation didn't reach heap_prune_record_prunable either and also doesn't crash.