BUG #14231: logical replication wal sender process spins when using error traps in function

From: blake(at)rcmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14231: logical replication wal sender process spins when using error traps in function
Date: 2016-07-06 18:55:02
Message-ID: 20160706185502.1426.28143@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14231
Logged by: Michael Day
Email address: blake(at)rcmail(dot)com
PostgreSQL version: 9.4.6
Operating system: FreeBSD 10.1-RELEASE
Description:

The following function can be used to reproduce an issue with logical
replication (version 9.4.6).

Connect a logical client with test_decoding plugin and run the code below.
It will cause the replication process to spin, using 100% CPU for some long
period of time.
Recovery time seems to exponentially increase depending on the number of
times the function is called.
It is impossible to prematurely stop the process without restarting the
server (it does not take notice of a disconnect).

CREATE TABLE IF NOT EXISTS test1 (id serial not null, value text);

CREATE OR REPLACE FUNCTION test1()
RETURNS void AS $$
BEGIN
BEGIN
INSERT INTO test1 (value) values (random()::text);
EXCEPTION WHEN unique_violation THEN
-- JUST having this exception handling block causes it to fail
END;
END;
$$ LANGUAGE plpgsql;

explain analyze SELECT test1() FROM generate_series(1, 50000);

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Martin Angelovski 2016-07-06 19:35:15 pgAdmin3 1.22.1 crashes constantly on Mac os 10.11.5
Previous Message Marco Nenciarini 2016-07-06 15:57:34 Re: BUG #14230: Wrong timeline returned by pg_stop_backup on a standby