From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: blake@rcmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14231: logical replication wal sender process spins when using error traps in function
Date: Wed, 06 Jul 2016 22:00:46 +0100
Message-ID: <878txea5b4.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <20160706185502.1426.28143@wrigleys.postgresql.org>
References: <20160706185502.1426.28143@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
>>>>> "blake" == blake <blake@rcmail.com> writes:
blake> Connect a logical client with test_decoding plugin and run the
blake> code below. It will cause the replication process to spin,
blake> using 100% CPU for some long period of time.
So what I've found in my analysis so far since you mentioned this on IRC
is:
1. The time is being spent in ReorderBufferCleanupTXN and the functions
it calls. This is called once for the transaction and (recursively) once
per subtransaction.
2. Within each of those calls, the main culprit seems to be pathological
behavior of the retail pfree() calls of allocated memory. The loop in
AllocSetFree which chases down the allocated block list (for chunks over
the chunk limit) is being executed nearly 900 million times for what
seems to be about 42 thousand calls.
A quick scan of the code suggests that the worst case is when blocks are
being freed in FIFO order, which seems quite plausible in this case, and
the performance is potentially O(N^2).
So I think this is primarily an artifact of doing so much retail
palloc/pfree in a single memory context.
--
Andrew (irc:RhodiumToad)
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andrew@tao11.riddles.org.uk, blake@rcmail.com
Subject: Re: BUG #14231: logical replication wal sender process spins when using error traps in function
In-Reply-To: <878txea5b4.fsf@news-spur.riddles.org.uk>
References: <20160706185502.1426.28143@wrigleys.postgresql.org> <878txea5b4.fsf@news-spur.riddles.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox