Logical replication ApplyContext bloat

From: Stas Kelvich <s(dot)kelvich(at)postgrespro(dot)ru>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Logical replication ApplyContext bloat
Date: 2017-04-18 11:45:46
Message-ID: 9A2F6FEC-D510-4AD6-8082-A1021040C840@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

currently logical replication worker uses ApplyContext to decode received data
and that context is never freed during transaction processing. Hence if publication
side is performing something like 10M row inserts in single transaction, then
subscription worker will occupy more than 10G of ram (and can be killed by OOM).

Attached patch resets ApplyContext after each insert/update/delete/commit.
I’ve tried to reset context only on each 100/1000/10000 value of CommandCounter,
but didn’t spotted any measurable difference in speed.

Problem spotted by Mikhail Shurutov.

Attachment Content-Type Size
applycontext_bloat.patch application/octet-stream 1.0 KB
unknown_filename text/plain 96 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2017-04-18 11:52:28 Re: SCRAM authentication, take three
Previous Message Maksim Milyutin 2017-04-18 11:13:00 Re: Proposal: Local indexes for partitioned table