Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iXuCc-0000vf-K0 for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Nov 2019 21:41:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iXuCb-0001La-F8 for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Nov 2019 21:41:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iXuCa-0001LQ-UP for pgsql-bugs@lists.postgresql.org; Thu, 21 Nov 2019 21:41:25 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iXuCW-0007fA-Vs for pgsql-bugs@lists.postgresql.org; Thu, 21 Nov 2019 21:41:23 +0000 Received: by mail-wr1-x444.google.com with SMTP id 4so2925819wro.7 for ; Thu, 21 Nov 2019 13:41:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=8HMc+WC+vUnLyAkkzdwnHJnCn79i9vYHYYIU5RfFm30=; b=Z3MgWkt4XcFb/xk/aycvAcwkRRXyplxpT8/8TjAVwpn1e1f0jL6W6BgD8x4z9u/EVV bCtVnV+6YazQBo3R4Z8U53F5bQzgB++zvFw52FyFot0SVAXOJA37clNlR7943rEH9M+2 mwhJApiekzUQRsHg/Aed8rG6VwecH3rjICXYeV97SucZp3oE1yi6BdIKBJcAdCILDQo2 kQCxHU1z29EAoZKvW+lET5LYnhGVM/B3G9H08uZF7wNqxmAWY4ZN3Y/KroJRatJxp81k TUnwzKvAVbAnpUulemP9clgpuV0q+cmx20ZyMR3vd8FmbYVs7QeBhkdLVICim8ZIqOSE 6GAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=8HMc+WC+vUnLyAkkzdwnHJnCn79i9vYHYYIU5RfFm30=; b=RVFdMaL/b1XZc+9fPsyjGsWKoFV0bd7VSJRUefdiO+5HJHv09B7sCp5Glkv5LJi5sh 4cmqgNw2XtQFEQl5hEyqY/U5TqhnXv3OZicUvCmwW0GpSuT5IkoovmPC7tJ4be7QlFBU lIJm4C/+Kvchfi5s1Z+5QLDSasOQe67bIpdgQIKd9mc02HtsSEg87ZZ/HLOZDuphgciM IsjDKZQYCqqFho1UPt1EBoKBIoUf4U29eDgk18Kfk5aso6DEucsjrH8xPvNv2FUoAFBy nxJOKHGOUP1EAgx2KgEm6A1ymf69GQpyT2p13J1X4BzxY9Hn6WsZqBoTlJrbS2hkPkLr GLcg== X-Gm-Message-State: APjAAAUzyDSxMCHrUUzo5jN5T4ciLOnr7Gyu3Zvb6IlWHDKkinB78hrh bGkJLV5ofkeyIS2X8WlDF/freA== X-Google-Smtp-Source: APXvYqzZGfpwwF373hkMdYTYec8CAZ9wHjWzdDhGy34HtynWqXrYYAmE3jd9q2lyFwrp2ugL3FwwGg== X-Received: by 2002:adf:a3d5:: with SMTP id m21mr13378526wrb.386.1574372479589; Thu, 21 Nov 2019 13:41:19 -0800 (PST) Received: from localhost (ip-86-49-253-92.net.upcbroadband.cz. [86.49.253.92]) by smtp.gmail.com with ESMTPSA id l13sm1016815wmh.12.2019.11.21.13.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 13:41:18 -0800 (PST) Date: Thu, 21 Nov 2019 22:41:15 +0100 From: Tomas Vondra To: =?utf-8?Q?Ond=C5=99ej?= Jirman Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16129: Segfault in tts_virtual_materialize in logical replication worker Message-ID: <20191121214115.3tgefmvkmrzaim74@development> References: <20191121133237.vgxoilemblaqmstu@development> <20191121135523.aybyo7o6yzxxungd@core.my.home> <20191121143503.nkdwgjwb7xjopeuq@development> <20191121150716.szxqukxrtpjpckm3@core.my.home> <20191121152732.hu6y4wzw7nkxpsvk@development> <20191121155707.pqkgjphh65o5fapz@core.my.home> <20191121161502.xfiy65i3cm6adscr@core.my.home> <20191121165752.dffge6bh756xlfdg@development> <20191121173555.midj6vp4dmiiqs24@core.my.home> <20191121185844.6qsqhwzzuhu3fpsg@core.my.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191121185844.6qsqhwzzuhu3fpsg@core.my.home> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Nov 21, 2019 at 07:58:44PM +0100, Ondřej Jirman wrote: >On Thu, Nov 21, 2019 at 06:35:55PM +0100, Ondřej Jirman wrote: >> One missing piece is what exactly is the contents of the outstanding output from >> pgoutput plugin, that the replica crashes on and doesn't apply. Are there any >> tools for inspecting the binary output from the pgoutput plugin? Maybe that can >> provide a clue. > >So I've looked at it manually, and the segfaulting transaction doesn't make >much sense to me. On primary a row with 37880 byte cover_image was inserted, >but pgoutput plugin sends these records: > >B >R - public.videos title cover_image metadata,... >U - new row where cover_image tuple doesn't have any data, just a flag ('u') >C > >Which means 'unchanged toast column' according to logical/proto.c > >Yet cover_image is defined as not null. > >I guess it's some special handling for VARATT_IS_EXTERNAL_ONDISK. Actually, no. The second message is 'U' so update, not insert. And we don't send TOAST values (oversized values, stored aside) that were not updated. Which is this case, because the cover_image was not updated (as implied by the 'u' flag). For the record, the decoded data looks like this: 1) relation structure (8 columns) R, 19048, public, videos, d, 8, (true, id, 23 => int4, 0xffffffff) (false, title, 25 => text, 0xffffffff) (false, cover_image, 17 => bytea, 0xffffffff) (false, metadata, 3802 => jsonb, 0xffffffff) (false, category, 23 => int4, 0xffffffff) (false, published, 1082 => date, 0xffffffff) (false, added, 1114 => timestamp, 0xffffffff) (false, played, 16 => uuid, 0xffffffff) 2) update, with the TOAST value undefined/unchanged U, 19048, N, 8, (4, 8393), (86, Pazderka: O média se povede boj. Kdyby nás politici milovali, bylo by něco špatně), u, /* unchanged bytea */ (313, {.. json ..}), (3, 242), (10, 2019-11-18), (26, 2019-11-18 12:50:01.816376), (1, t) So it's perfectly well formatted, I think. > >To me this looks like this transaction is assuming data for bytea column >cover_image are already replicated from earlier? > >Maybe it is not though? It's certainly breaking some assumption on the >replica, because this is the precise point where segfault happens. > I think this more and more seems like some sort of bug in the apply code, not resetting a NULL flag and interpreting the bogus value as a valid pointer. Wouldn't the be the first such bug. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services