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 1oeMs6-0007cJ-Gv for pgsql-committers@arkaria.postgresql.org; Fri, 30 Sep 2022 20:44:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oeMs5-0007A3-DD for pgsql-committers@arkaria.postgresql.org; Fri, 30 Sep 2022 20:44:33 +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 1oeMs5-00079u-2f for pgsql-committers@lists.postgresql.org; Fri, 30 Sep 2022 20:44:33 +0000 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oeMs2-0003AZ-0Y for pgsql-committers@lists.postgresql.org; Fri, 30 Sep 2022 20:44:32 +0000 Received: by mail-qv1-xf31.google.com with SMTP id i12so3548680qvs.2 for ; Fri, 30 Sep 2022 13:44:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systemguards-com-ec.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=tRewWO5jOfWub1ZGSuVTuoOO3kGdazL9hAfSsT2QT6E=; b=lB8aDJy1JXCJ12R+S4HVpauR3u7CmCAG4fLcllG9racI9Uj5hV+NU5jC6mUrFiis3K bU7TtX9KIyfd2PqgghvormQTGP7xBhmHkJcF4atQG7SY8aqeTccol2gNJUH700XQMC81 BgPLQ/YlMxhDqOpjwAJWwUR5oA4ms+JUuarbtr9+UY2U0FViSKIUryKTBnIOIEJaxMwh AKMLh5Mg139xrcyaAgj4RHx3g1xGpUuPbGdbDRSagGAvf5dY3vw4cP4q8v7pGN6NiE5D yNgdIN4G5+sHAiMqRlQUdmiM+NelUncsGXkaXOudQ8L/x9HnSU72h5Ic/gg0KjoYQOm7 DHjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=tRewWO5jOfWub1ZGSuVTuoOO3kGdazL9hAfSsT2QT6E=; b=LNB8HXiZ4eHKZDqX3VH+3Jps9nMTHb2Ea+UIZhnhk+NgNplSts4MRBXscBfSRvV+fl ZIXM2Dft4+74G41tZK9hqZOehMvCyEwoUMP4376NJ0ccho4hIFrwJSN8ipijQqrIauqz HBepOBwSQmhcLopVl/nt07bN3lS4OyF+1cDLpUiRRGsmKql7FwqUeXMTrcSn0+beJSh9 q5U04O99nQy+0igM1UmjEFgIIgrMmAE8qBcUBCOBXYPa7WgC8FtGyCwxHJah3TpG+lxu V6Pw9bwEnvf/XPxOxFBWAiiQhAXAJAB30qYwnJsSShxo/DOWyNaojvI/fcutSwISBD5j 0FzQ== X-Gm-Message-State: ACrzQf2lFNKiDzaWabdr5ZKICXa+Q3GDcIxwjgiI3B8MDGhYyvLD02I1 N+suQnlvkiZ60ig6iSrD4CbdCtEZJuUdsg== X-Google-Smtp-Source: AMsMyM5KV9VZu5YKD5XPckX5teG88IH01nIz43pXmzSgaLfU5pC/Z7EG3gSWYXXGdzgdbQ4fxbbisw== X-Received: by 2002:ad4:5f4b:0:b0:4af:9458:7dc3 with SMTP id p11-20020ad45f4b000000b004af94587dc3mr8474254qvg.91.1664570667866; Fri, 30 Sep 2022 13:44:27 -0700 (PDT) Received: from ahch-to ([201.183.1.162]) by smtp.gmail.com with ESMTPSA id fb25-20020a05622a481900b0034035e73be0sm2779480qtb.4.2022.09.30.13.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 13:44:27 -0700 (PDT) Date: Fri, 30 Sep 2022 15:44:22 -0500 From: Jaime Casanova To: Tom Lane Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Avoid improbable PANIC during heap_update. Message-ID: References: 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 Thu, Sep 29, 2022 at 02:55:40AM -0500, Jaime Casanova wrote: > On Tue, Apr 13, 2021 at 04:17:39PM +0000, Tom Lane wrote: > > Avoid improbable PANIC during heap_update. > > > > heap_update needs to clear any existing "all visible" flag on > > the old tuple's page (and on the new page too, if different). > > Per coding rules, to do this it must acquire pin on the appropriate > > visibility-map page while not holding exclusive buffer lock; > > which creates a race condition since someone else could set the > > flag whenever we're not holding the buffer lock. The code is > > supposed to handle that by re-checking the flag after acquiring > > buffer lock and retrying if it became set. However, one code > > path through heap_update itself, as well as one in its subroutine > > RelationGetBufferForTuple, failed to do this. The end result, > > in the unlikely event that a concurrent VACUUM did set the flag > > while we're transiently not holding lock, is a non-recurring > > "PANIC: wrong buffer passed to visibilitymap_clear" failure. > > > > Hi, > > This doesn't look as improbable because I saw it at least 3 times with > v15beta4. > > The first time I thought it was my fault, then I tried with a commit on > september 25 (didn't remember which exactly but that doesn't seems too > relevant). > Finally I saw it again in a build with TRACE_VISIBILITYMAP defined (the > same commit). > > But I haven't see it anymore on rc1. Anyway I'm attaching the backtrace > (this is from the build with TRACE_VISIBILITYMAP), the query that was > running at the time was (no changes were made to quad_poly_tbl table > nor any indexes were added to this table): > > """ > update public.quad_poly_tbl set > id = public.quad_poly_tbl.id > returning > public.quad_poly_tbl.id as c0 > """ > Just to confirm I saw this on RC1 -- Jaime Casanova Director de Servicios Profesionales SystemGuards - Consultores de PostgreSQL