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 1lqrQY-00043I-JU for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Jun 2021 06:10:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lqrQX-0001vY-EQ for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Jun 2021 06:10:57 +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 1lqrQX-0001vP-43 for pgsql-hackers@lists.postgresql.org; Wed, 09 Jun 2021 06:10:57 +0000 Received: from mail-yb1-xb2e.google.com ([2607:f8b0:4864:20::b2e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lqrQU-0004Ts-It for pgsql-hackers@postgresql.org; Wed, 09 Jun 2021 06:10:56 +0000 Received: by mail-yb1-xb2e.google.com with SMTP id g38so33824295ybi.12 for ; Tue, 08 Jun 2021 23:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ChtvrBoe2JSRT3yAUyxUJ3geRlDMemr1dkBu/a4rZwk=; b=IeotSEcgsdKfB0/XwCcZGrHUI3I+5IsT59z5SXD0bZ1HYN8NgAq+AnCNdQsvT3BSAE ImLUD5oH7R03+7O06CMiFvIf22QIbBgJA7HSUYvrvDC5h3OlS0d0DI8h1qADelv8+R0R BtNz00boO19zMn9ZjHpA/bY8WRVUwGexEjM2HPsEqe9ZgCqOvmk7jd3ni+xfpkWTeu5w Yeyt9LfKWGfenQgY1DXUia8Yo8gQoqku9VJTilc9BSChGpp3VB6d/OhChLqROMztT83U Dt11OodnQc55nSMgTXN59cvO0WQ3GO/fymbN8afQksxPAe9ZLaOQVZPi+nhX5/fWI4sP 5K/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ChtvrBoe2JSRT3yAUyxUJ3geRlDMemr1dkBu/a4rZwk=; b=l92jz35ocr/JKKv4ZaW5SsP/VoCt4KRMWindSMGHOf8VUAOb9N3rSRTwBBt8FaNrJO VLjSoAhWZ80BHCgPXX7Hv5U96/wODAKQ0gbabVR4yzafesbr4okZIRnzi6rhgSyJGm3+ apAMqaPAQ7EzdOtQ09JN5EaZajttOVwdW0METgfr/KezZpk41lslhaSloomX2TOZD5Pf sOjaqaJsJX6nWvSxXWCkDrmEue+Sj1SZ54XQ32YMtWpF0VhSBAkI1vbuavFs5OMZUMxs af6YaeZH+OIDWiWRf/mARCrYbKXsDo2rbq54i1GLRlDD9DKPG3cAPxCqsRko4/bA0HH3 3oOg== X-Gm-Message-State: AOAM53327keEbZxt5S/tbIf09WA/AfpEXJqAblVZU1lyWcqyV/m79F/4 3AzVKuSJd64Vd0t6CS3nW4IyJNnpuKy04BDaMxY= X-Google-Smtp-Source: ABdhPJwrafvtMZOMxzHUMrDFFF0av+M6fPi8QSs9DkQbdAIz+0qq9TROgyEy8+WQ+Imm8or9yZq7iDtuwYq99eCq8Fw= X-Received: by 2002:a25:1e43:: with SMTP id e64mr33766214ybe.489.1623219052607; Tue, 08 Jun 2021 23:10:52 -0700 (PDT) MIME-Version: 1.0 References: <202106042335.o64q6dui5hu2@alvherre.pgsql> <444215b4-8fb5-6a82-a534-645abafbffb4@amazon.com> <8d45ed72-1706-8b21-75a6-a3420bd15b04@amazon.com> In-Reply-To: <8d45ed72-1706-8b21-75a6-a3420bd15b04@amazon.com> From: Amit Kapila Date: Wed, 9 Jun 2021 11:40:41 +0530 Message-ID: Subject: Re: logical decoding bug: segfault in ReorderBufferToastReplace() To: "Drouvot, Bertrand" Cc: Jeremy Schneider , Alvaro Herrera , Andres Freund , Tomas Vondra , PostgreSQL-development 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 Wed, Jun 9, 2021 at 11:37 AM Drouvot, Bertrand wro= te: > > On 6/9/21 5:33 AM, Amit Kapila wrote: > > On Wed, Jun 9, 2021 at 12:06 AM Jeremy Schneider = wrote: > >> On 6/4/21 23:42, Amit Kapila wrote: > >> > >> On 2021-Jun-04, Jeremy Schneider wrote: > >> > >> ERROR: XX000: could not open relation with OID 0 > >> LOCATION: ReorderBufferToastReplace, reorderbuffer.c:305 > >> > >> Even, if this fixes the issue, I guess it is better to find why this > >> happens? I think the reason why the code is giving an error is that > >> after toast insertions we always expect the insert on the main table > >> of toast table, but if there happens to be a case where after toast > >> insertion, instead of getting the insertion on the main table we get > >> an insert in some other table then you will see this error. I think > >> this can happen for speculative insertions where insertions lead to a > >> toast table insert, then we get a speculative abort record, and then > >> insertion on some other table. The main thing is currently decoding > >> code ignores speculative aborts due to which such a problem can occur. > >> Now, there could be other cases where such a problem can happen but if > >> my theory is correct then the patch we are discussing in the thread > >> [1] should solve this problem. > >> > >> Jeremy, is this problem reproducible? Can we get a testcase or > >> pg_waldump output of previous WAL records? > >> > >> [1] - https://www.postgresql.org/message-id/CAExHW5sPKF-Oovx_qZe4p5oM6= Dvof7_P%2BXgsNAViug15Fm99jA%40mail.gmail.com > >> > >> > >> It's unclear to me whether or not we'll be able to catch the repro on = the actual production system. It seems that we are hitting this somewhat co= nsistently, but at irregular and infrequent intervals. If we are able to ca= tch it and walk the WAL records then I'll post back here. > >> > > Okay, one thing you can check is if there is a usage of Insert .. On > > Conflict .. statement in the actual production system? > > Yes that's the case, so that a speculative abort record followed by an > insert on some other table looks a perfect valid scenario regarding this > current issue. > Okay, thanks for the confirmation. So the patch being discussed in that thread will fix your problem. --=20 With Regards, Amit Kapila.