From: | Ben Chobot <bench(at)silentmedia(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | pg_logical_slot_peek_changes crashes postgres when called from inside pl/pgsql |
Date: | 2017-10-04 20:59:20 |
Message-ID: | 73FBA179-C68C-4540-9473-71E865408B15@silentmedia.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
I'm probably doing something dumb, but even something dumb at this high level probably shouldn't result in a crash. I've tried with multiple decoders and get the same result. I also have a stack trace from 9.5.5, if that helps: https://paste.depesz.com/s/Bu <https://paste.depesz.com/s/Bu>
postgres(at)c61-pg509:~$ psql
psql (9.5.9)
Type "help" for help.
postgres=# select version();
version
--------------------------------------------------------------------------------------------------------
PostgreSQL 9.5.9 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4, 64-bit
(1 row)
postgres=# SELECT * FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
slot_name | xlog_position
-----------------+---------------
regression_slot | 541/180342D0
(1 row)
postgres=# SELECT * FROM pg_replication_slots;
slot_name | plugin | slot_type | datoid | database | active | active_pid | xmin | catalog_xmin | restart_lsn
-----------------+---------------+-----------+--------+----------+--------+------------+------+--------------+--------------
regression_slot | test_decoding | logical | 12379 | postgres | f | | | 287608852 | 541/18034298
(1 row)
postgres=# CREATE TABLE public.foo(i int);
CREATE TABLE
postgres=# insert into public.foo(i) values(1);
INSERT 0 1
postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL);
location | xid | data
--------------+-----------+----------------------------------------
541/18034360 | 287608852 | BEGIN 287608852
541/180438D0 | 287608852 | COMMIT 287608852
541/180438D0 | 287608853 | BEGIN 287608853
541/180438D0 | 287608853 | table public.foo: INSERT: i[integer]:1
541/18043940 | 287608853 | COMMIT 287608853
(5 rows)
postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, 1);
location | xid | data
--------------+-----------+------------------
541/18034360 | 287608852 | BEGIN 287608852
541/180438D0 | 287608852 | COMMIT 287608852
(2 rows)
postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, 1) limit 1;
location | xid | data
--------------+-----------+-----------------
541/18034360 | 287608852 | BEGIN 287608852
(1 row)
postgres=# CREATE OR REPLACE FUNCTION logical_replication_slot_lsn_delta(slot text) RETURNS pg_lsn AS
postgres-# $$
postgres$# BEGIN
postgres$# return location from pg_logical_slot_peek_changes(slot,null,1) limit 1;
postgres$# END
postgres$# $$ language plpgsql;
CREATE FUNCTION
postgres=# select logical_replication_slot_lsn_delta('regression_slot'); # crash!
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
->
#...and to cleanup
postgres(at)c61-pg509:~$ psql
psql (9.5.9)
Type "help" for help.
postgres=# select pg_drop_replication_slot('regression_slot');
pg_drop_replication_slot
--------------------------
(1 row)
postgres=# drop table public.foo;
DROP TABLE
From | Date | Subject | |
---|---|---|---|
Next Message | Paul Mendoza | 2017-10-04 23:42:07 | Postgresql 9.6.5 not working in Windows Docker containers (both Nanoserver and WindowsServerCore base images) |
Previous Message | Andres Freund | 2017-10-04 17:56:07 | Re: Re: [PATCH] BUG #13416: Postgres >= 9.3 doesn't use optimized shared memory on Solaris anymore |