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 1iISVh-0000Fo-Ci for pgsql-general@arkaria.postgresql.org; Thu, 10 Oct 2019 07:05:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iISVf-0003Ey-VI for pgsql-general@arkaria.postgresql.org; Thu, 10 Oct 2019 07:05:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iISVf-0003Eq-G7 for pgsql-general@lists.postgresql.org; Thu, 10 Oct 2019 07:05:15 +0000 Received: from post.visena.com ([46.226.10.50]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iISVc-0005E3-Pt for pgsql-general@lists.postgresql.org; Thu, 10 Oct 2019 07:05:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=visena.com; s=20141101.wh; h=Content-Type:MIME-Version:Subject:In-Reply-To:Message-ID:Cc:To:From:Date; bh=woRgAtvwO94DUM5PrtVfKlkFLY5SEZUz8wY2/rndixo=; b=rGmSCAXAeihytlRKyn2X54G6gOyRLd7p8xjikYytTgZvCG62xlAd1+VlTHZrdJ/aLcOhpG2ZQl6p6V6yRCGHOMAGdESyW0dqexC+KnYNxuroJF1gUlToLoU9+yGMdGx1CbYyrdU/0Ci2KnTknBkAc9z7uAtovsN4d7PLUXnK6m8=; Received: from [10.0.1.10] (helo=tc7-visena.wh.internal.visena.com) by post.visena.com with esmtp (Exim 4.82) (envelope-from ) id 1iISVX-00006L-0b; Thu, 10 Oct 2019 09:05:09 +0200 Received: from localhost ([127.0.0.1] helo=tc7-visena.wh.internal.visena.com) by tc7-visena.wh.internal.visena.com with esmtp (Exim 4.90_1) (envelope-from ) id 1iISVW-0004Uc-N2; Thu, 10 Oct 2019 09:05:06 +0200 Date: Thu, 10 Oct 2019 09:05:06 +0200 (CEST) From: Andreas Joseph Krogh To: Andres Freund Cc: Tom Lane , pgsql-general@lists.postgresql.org, Torstein Tauno Svendsen Message-ID: In-Reply-To: <877e5duq7t.fsf@alap4.lan> Subject: Re: Segmentation fault with PG-12 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_105_1212765035.1570691106583" X-Mailer: Visena Mail 2.2.141 X-Spam-Score: -1.0 X-Spam-Report: SpamAssasin (score=-1.0, required 5.0 ALL_TRUSTED=-1,HTML_MESSAGE=0.001) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_105_1212765035.1570691106583 Content-Type: multipart/related; boundary="----=_Part_106_1871941996.1570691106583" ------=_Part_106_1871941996.1570691106583 Content-Type: multipart/alternative; boundary="----=_Part_107_2137163814.1570691106607" ------=_Part_107_2137163814.1570691106607 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable P=C3=A5 torsdag 10. oktober 2019 kl. 07:25:26, skrev Andres Freund < andres@anarazel.de >: On 2019-10-09 10:16:37 -04= 00,=20 Tom Lane wrote: > Andreas Joseph Krogh writes: > > Attached is output from "bt full". Is this helpful? > > Well, it shows that the failure is occurring while trying to evaluate > a variable in a trigger's WHEN clause during > "UPDATE origo_email_delivery SET folder_id=3D$1, created=3D$2\nWHERE ent= ity_id=20 IN ($3)\nRETURNING entity_id" > And I'd bet that the root cause is something to do with Andres' tuple sl= ot > work. But (at least to my eye) it's not apparent exactly what's wrong. It looks like this could "just" be another report of #16036, which was already fixed in: commit d986d4e87f61c68f52c68ebc274960dc664b7b4e Author: Andres Freund Date: 2019-10-04 11:59:34 -0700 Fix crash caused by EPQ happening with a before update trigger present. (Tom: This mail is only viewable as text/html, to if you're reading the=20 text/plain version it will seem "hashed") Aha, that whould be=20 60e97d63e5d19098e11fa32431a20eea820e2ae9 in REL_12_STABLE We'll build and r= un=20 HEAD of REL_12_STABLE, and report back. > This doesn't seem to correlate wi= th=20 your original report, btw, > as that claimed the crash was during COMMIT. That however, would be confusing, unless there's some deferred trigger that causes another update, which then fires a before update trigger causing the problem. Greetings, Andres Freund We have a deferred trigger which updates origo_email_deliver= y:=20 CREATE OR REPLACE FUNCTIONorigo_index_email_props_tf() RETURNS TRIGGER AS $= $=20 declare v_prop origo_email_message_property; BEGIN v_prop :=3D NEW; UPDATE= =20 origo_email_delivery SET is_seen =3D v_prop.is_seen, followup_id =3D=20 v_prop.followup_id, is_replied =3D v_prop.is_replied, is_forwarded =3D=20 v_prop.is_forwarded, is_draft =3D v_prop.is_draft, is_done =3D v_prop.is_do= ne,=20 is_flagged =3D v_prop.is_flagged, modseq =3Dgreatest(modseq, v_prop.modseq)= WHERE=20 message_id =3D v_prop.message_idAND owner_id =3D v_prop.owner_id; RETURN NE= W; END;=20 $$LANGUAGE plpgsql; CREATE CONSTRAINT TRIGGER origo_index_email_props_t AFT= ER=20 INSERT OR UPDATE ON origo_email_message_property DEFERRABLE INITIALLY DEFER= RED =20 FOR EACH ROWEXECUTE PROCEDURE origo_index_email_props_tf(); .. and then tri= gger=20 the following UPDATE-trigger: CREATE TRIGGER origo_email_delivery_update_t= =20 BEFORE UPDATE ON origo_email_delivery FOR EACH ROW WHEN (OLD.folder_id <> = NEW .folder_idOR NEW.is_deleted <> OLD.is_deleted) EXECUTE PROCEDURE=20 origo_email_delivery_update_tf(); Maybe that will trigger the bug. Thanks. = --=20 Andreas Joseph Krogh CTO / Partner - Visena AS Mobile: +47 909 56 963=20 andreas@visena.com www.visena.com=20 ------=_Part_107_2137163814.1570691106607 Content-Type: text/html;charset=UTF-8 Content-Transfer-Encoding: quoted-printable
P=C3=A5 torsdag 10. oktober 2019 kl. 07:25:26, skrev Andres Freund <= ;andres@anarazel.de>:
On = 2019-10-09 10:16:37 -0400, Tom Lane wrote:
> Andreas Joseph Krogh <andreas@visena.com> writes:
> > Attached is output from "bt full". Is this helpful?
>
> Well, it shows that the failure is occurring while trying to evaluate<= br> > a variable in a trigger's WHEN clause during
> "UPDATE origo_email_delivery SET folder_id=3D$1, created=3D$2\nWH= ERE entity_id IN ($3)\nRETURNING entity_id"
> And I'd bet that the root cause is something to do with Andres' tuple = slot
> work.=C2=A0 But (at least to my eye) it's not apparent exactly what's = wrong.

It looks like this could "just" be another report of #16036, whic= h was
already fixed in:

commit d986d4e87f61c68f52c68ebc274960dc664b7b4e
Author: Andres Freund <andres@anarazel.de>
Date:=C2=A0 =C2=A02019-10-04 11:59:34 -0700

=C2=A0 =C2=A0 Fix crash caused by EPQ happening with a before update trigge= r present.

=C2=A0
=C2= =A0
=C2= =A0
(Tom: This mail is on= ly viewable as text/html, to if you're reading the text/plain version it wi= ll seem "hashed")
=C2=A0
Aha, that whould be=C2=A060e97d63e5d19098e11fa32431a20eea820e2ae9 in= =C2=A0REL_12_STABLE
We'll build and run HEAD of REL_12_STABLE, and report back.
=C2=A0
=C2=A0
> This doesn't s= eem to correlate with your original report, btw,
> as that claimed the crash was during COMMIT.

That however, would be confusing, unless there's some deferred trigger
that causes another update, which then fires a before update trigger
causing the problem.

Greetings,

Andres Freund
=C2=A0
We have a deferred trigger which updates=C2=A0origo_email_delivery:
=C2=A0
CREATE OR REPLACE FUNCTION =
origo_index_email_props_tf=
() RETURNS TRIGGER AS
$$
declare
    v_prop origo_email_message_property<=
/span>;
BEGIN
    v_prop :=
=3D NEW;
    UPDATE origo_email_delivery
    SET is_seen      =3D v_prop.i=
s_seen,
        followup_id  =3D v_prop.followup_id,
        is_replied   =3D v_prop.is_replied,
        is_forwarded =3D v_prop.is_forwarded,
        is_draft     =3D v_prop.is_draft,
        is_done      =3D v_prop.is_done,
        is_flagged   =3D v_prop.is_flagged,
        modseq       =3D greatest=
(modseq, v_prop.modseq)
    WHERE message_id =3D v_prop.message=
_id
      AND owner_id =
=3D v_prop.owner_id;
    RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE CONSTRAINT TRIGGER <=
/span>origo_index_email_props_t
    AFTER INSERT OR UPDATE
    ON origo_email_message_property DEFERRABLE INITIALLY DEF=
ERRED
    FOR EACH ROW
EXECUTE PROCEDURE origo_index_email_props_tf()=
;
=C2=A0
.. and then trigger the following UPDATE-trigger:
=C2=A0
CREATE TRIGGER origo_email_delivery_update_t
    BEFORE UPDATE
    ON origo_email_d=
elivery
    FOR EACH ROW
    WHEN <=
/span>(OLD=
.folder_id <> NEW.folder_id OR NEW.is_deleted <> OLD.is_deleted)
EXECUTE PROCEDURE=
 origo_email_delivery_update_tf<=
/span>();
=C2=A0
Maybe that will trigger the bug.
=C2=A0
Thanks.
=C2=A0
--
">
Andrea= s Joseph Krogh
CTO / Partner<= /span> - Visena AS
Mobile: +47 90= 9 56 963
=3D""
=C2=A0
------=_Part_107_2137163814.1570691106607-- ------=_Part_106_1871941996.1570691106583 Content-Type: image/png Content-Transfer-Encoding: base64 Content-Disposition: inline Content-ID: iVBORw0KGgoAAAANSUhEUgAAAIUAAAAYCAYAAADUIj6hAAAABHNCSVQICAgIfAhkiAAABzBJREFU aEPtmNFxHDcMhmVP3i1VECpvnjzkVIHWFfhcgVcVRKrAUgWRK/C6Al8H3lTgy0PGbzFdQc4VJP/H ADs43q6kROeJNbOYgQACIAgCWJKng4MZ5gxUGXh0U0b+SIuF9G+EWXj2Q15vbrE/NPtk9uub7Gfd t5mBx1NhqSEo8HshjbEUtlO2yIM9tsx5dZP9rPt2MzDZFAqZE4LGcFjdsg3saQaHt7fY70X949On aS+OZidDBkavD33157L4xaw2os+Mp/DAC10l2XhOCeStj0W5ajrJL8WfCi80Xgf9vVlrhg9yRONe /f7xI2vNsIcM7JwU9o6oGyJrLT8JOA1aX9sKP4wl94bAniukEbo/n7YPmuTETzIab4Y9ZWCrKexd 8M58lxPCvvD6aihfvexbEQoPYO8NQRO0JnddGO6FJYaVsBde7cXj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