Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHOj2-0003RZ-Fg for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Oct 2018 07:46:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gHOiz-0002UD-W2 for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Oct 2018 07:46:05 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1gHOiz-0002U1-Pc for pgsql-bugs@lists.postgresql.org; Tue, 30 Oct 2018 07:46:05 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gHOiv-0006EZ-Dj for pgsql-bugs@lists.postgresql.org; Tue, 30 Oct 2018 07:46:05 +0000 Received: by mail-wr1-x42b.google.com with SMTP id 74-v6so3182864wrb.13 for ; Tue, 30 Oct 2018 00:46:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=uf1VAtZdYdN4rCNzakmpSV2YT100SafXJd5FrPSQ+gA=; b=GIZtr1lRbZlMzRtKOsBYo3B1ZqZnTo+oYnUWPoeidipcQEnvvVW1NP8u/SAqqSDOFd H12P0/+G/o6qGTVOpKZlG+gv+AQnu3NSfsw5ODoDQSpxc/q6WIlzi/KUYkD98piKjdS5 WXdcHngzt6Vv7aUIdJpNPcZdbsvyGsLgnRpiWAB12Wj6XH7GtHQaYbrWkEHUMxwQ++dm SeU9X/KIWZ7TX8ZXj+uF9+NOWQbcq/2Ls7IBnbL0WB+by5OHZcpAbrzlnoVxH2ITd8Yb O4kw/oKl4KPFLRDEpiqUFKwVFx3ld4V5mp59gZvZGT1HKTwsc22t2K9Jpc1kiq3z1q22 6wKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=uf1VAtZdYdN4rCNzakmpSV2YT100SafXJd5FrPSQ+gA=; b=QrIh6pfkV2IgYKMBym/ZClAUoIhCJalCAHobeqobC59Ib26W9OBBMRAnoiZZN7ii4I edwytKuECCD6fZmEDrCtz0izV9Ufdwsq6EEz7utcNA13Iru/fr165CIUag+z3EYZ4vGj fsNikjXbYQPIUctJjE1biwfjRmm2JhrTy05+ViFTTlaaNNLZBJQhB/PmIB49HdLh58UD U2Zi9ikWScwFDv40bvIH7p1Eqda5zspr0s25YpyajtDMiPSe/uwtjI0mnAv5XfFPvxX4 Pao+uTII6pQZGIdyju9qP4OBfnYko+8q7AaAll3+fTIURQT61JCmDPedni2LmBNb+MpM fFEw== X-Gm-Message-State: AGRZ1gLkP12Yhnb75f//eRuhiWGeQEhJJN2nUQPj0E/RboT7Jlee3WTv 676fLoaP13z5TdZOP6wetUUDqA== X-Google-Smtp-Source: AJdET5fwBwDt9YHUs5He+8DmwcHx0e+Nv5h+SGruxG7wR6+oAcV5ireqRLHExPDHyobOVr+EQSt09w== X-Received: by 2002:a5d:4a48:: with SMTP id v8-v6mr16162313wrs.259.1540885559434; Tue, 30 Oct 2018 00:45:59 -0700 (PDT) Received: from [192.168.0.99] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id j16-v6sm16852527wrq.89.2018.10.30.00.45.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 00:45:58 -0700 (PDT) Subject: Re: BUG #15114: logical decoding Segmentation fault To: Michael Paquier Cc: =?UTF-8?B?0J/QtdGC0YrRgCDQodC70LDQstC+0LI=?= , Alvaro Herrera , Andres Freund , Petr Jelinek , pgsql-bugs@lists.postgresql.org, Peter Eisentraut References: <20180326160801.ja4j43hwrc35iuhb@alvherre.pgsql> <20180416175901.mdevawuuhvwo3yk6@alvherre.pgsql> <20180427012203.GG3419@paquier.xyz> <11af0d1b-e48f-fba3-5b1e-49886f648f52@2ndquadrant.com> <20181029015438.GC14242@paquier.xyz> <4cc78025-2bdd-082d-fe38-a35366ba8867@2ndquadrant.com> <20181030062828.GB23393@paquier.xyz> From: Petr Jelinek Openpgp: preference=signencrypt Autocrypt: addr=petr.jelinek@2ndquadrant.com; prefer-encrypt=mutual; keydata= xsFNBFawwSABEAC45Vua8rSggpM2kkMMmoOHz51a+fi3OXFfnrStVh80pM2/J9nSzjrIKQKf H5PtRnoYzSKnoUDoLOkLwDYitK3HzUUWXma+AWAqef2Y0GSZ7A3jJkD+JHOfkpS1CIpkEB/e WjA8Wqegwzc/OEE5111/l0Q1e6jxgZI86h8MMnm35Of1Y6Lz4kqWCyxHhaTJKTCkq66ICQ2C VJkbvuUoEE+Hr/I38dPHTAqIlCnycVnJPLHBQ/UYGHR/USF8qI/qJJx6tJcNAEqz69QZ/VlY 31UyJHdYe5NtBVz+rYZCOVWfpe3crbHuq9FjAPT+xcZefdxridmMKuW8eBmmXI9iZ3EG+X8J IsdLWL8QoqW0lnO1otYz1QDjdOvbEpq+u5/TAU8pgtaYH2J+6/GaQ6hMLyLBkaIAtnqlLCzq pxXcxMsFT14P5/rZA7EbBI8RS1ZIWJBlS2oO+dtVuENLJUC0SpptaRyn/uyOIopt7hSmBekL SzFnet7P9qofFJY+fQEz84v0G1gvwonHGHiCGgLpbMdPtnfPzda1aiTURvvOD7w/RmX1/ogk TqSGO4ejVNO/28QYouxmxzy8jb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2tQyh4fNQT1tGdBigtvzI4nHM1/1 PLJtJBdRHucP76vUH9RlP9EE/Sg5DFQqsfSYPqxLW9r+ZfSEeT0APdz7TQC9MzNzUhyXvA5a RQQCRMXKbGaYhKkYEYiYOGqtTxN+PmyvNUBmFEcagBX2TXqEkgnI6zOnN13mB4SihJ2lne2r 9RNiPYs/hmRxYg== Message-ID: <19dfa54d-6c4a-744a-d78a-4845b8da8241@2ndquadrant.com> Date: Tue, 30 Oct 2018 08:45:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181030062828.GB23393@paquier.xyz> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 30/10/2018 07:28, Michael Paquier wrote: > On Mon, Oct 29, 2018 at 04:03:31PM +0100, Petr Jelinek wrote: >> The reason why it breaks for OP is that his IMMUTABLE function is not >> actually IMMUTABLE, that's also why we don't see it reported much. > > Thanks, Petr. I have missed that part. Now I can see the failure > easily. Please note that on the receiver side you have the same > problem, RelationGetIndexAttrBitmap() is still being used in > logicalrep_rel_open() so that crashes the receiver: > #18 0x0000563cc278baa4 in RelationGetIndexPredicate > (relation=0x7f9764cdc050) at relcache.c:4720 > #19 0x0000563cc22ccdd6 in BuildIndexInfo (index=0x7f9764cdc050) at > index.c:1789 > #20 0x0000563cc278be4f in RelationGetIndexAttrBitmap > (relation=0x7f9764de52e8, attrKind=INDEX_ATTR_BITMAP_IDENTITY_KEY) at > relcache.c:4921 > #21 0x0000563cc25a6b0c in logicalrep_rel_open (remoteid=16388, > lockmode=3) at relation.c:313 The receiver side *should* actually use RelationGetIndexAttrBitmap, the problem there seems to be rather than we setup snapshot few lines of code too late in worker.c. > >> Given this I am not sure if we want to add test for this as it's >> something one should not do because it has unpredictable side effects, >> but if you think it will be useful anyway I can whip something out. > > Hmm. People should not do that but they can do it, so this thread is > telling is to be careful. Adding new objects in the schema of the > publisher and the receiver would be also cheap. A test like that is not > something we would see but I would suggest to stress the new routine on Well, considering we don't test for this misuse of IMMUTABLE anywhere else either, meh, but okay. > both sides. In the patch, something which makes me uncomfortable is > that get_rel_idattr() is a duplicate of the code paths taken by > RelationGetIndexAttrBitmap() when INDEX_ATTR_BITMAP_IDENTITY_KEY gets > used to fill in the relation cache. In this case, wouldn't we want to > just fetch the replica index instead of the full index list? I don't follow, we *do* only fetch replica index in the new function. > What is > proposed here needs more thoughts I think. Something that we could > consider on HEAD is to remove INDEX_ATTR_BITMAP_IDENTITY_KEY as it is > visibly unsafe. rd_idattr is also an unsafe concept. > I don't agree, about that, INDEX_ATTR_BITMAP_IDENTITY_KEY is perfectly safe when used correctly. Not sure what you mean regarding unsafety of rd_idattr but I don't see why it should not be safe. > Putting a safeguard in RelationGetIndexAttrBitmap() so as it generates > an ERROR if called in an output plugin, or just assert would be nice, > however such a check would need to use MyReplicationSlot (I don't recall > something else), and the limitations could just be documented as well. If we want to put additional Asserts it should be about having snapshot not about output plugin IMHO. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services