Re: pg_logical_slot_peek_changes crashes postgres when called from inside pl/pgsql

From: Andres Freund <andres(at)anarazel(dot)de>
To: Ben Chobot <bench(at)silentmedia(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: pg_logical_slot_peek_changes crashes postgres when called from inside pl/pgsql
Date: 2017-10-07 04:29:08
Message-ID: 20171007042908.edlsalmkm2ksac4y@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2017-10-06 21:24:34 -0700, Ben Chobot wrote:
>
> > On Oct 6, 2017, at 4:21 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >
> > I wrote:
> >> I thought of a better way, as attached.
> >
> > Pushed. Ben, could you confirm that the committed patch fixes your
> > original use-case? The 9.5 version of the patch is at
> >
> > https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=13d2ed921035f2d88adf87d796373e920bdd56ee
>
> Not quickly, to be honest. But the test case is not hard. If you can do this without crashing, I'm convinced you've fixed the problem as I've seen it:
>
>
> SELECT * FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
>
> CREATE TABLE public.foo(i int);
>
> insert into public.foo(i) values(1);
>
> CREATE OR REPLACE FUNCTION logical_replication_slot_lsn_delta(slot text) RETURNS pg_lsn AS
> $$
> BEGIN
> return location from pg_logical_slot_peek_changes(slot,null,1) limit 1;
> END
> $$ language plpgsql;
>
> select logical_replication_slot_lsn_delta('regression_slot');

Yep, that one's definitely fixed now.

Greetings,

Andres Freund

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2017-10-07 04:31:30 Re: pg_logical_slot_peek_changes crashes postgres when called from inside pl/pgsql
Previous Message Ben Chobot 2017-10-07 04:24:34 Re: pg_logical_slot_peek_changes crashes postgres when called from inside pl/pgsql