buffer refcount leak in foreign batch insert code

From: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Subject: buffer refcount leak in foreign batch insert code
Date: 2023-04-21 10:07:03
Message-ID: b035780a740efd38dc30790c76927255@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

We've found that in cases like the one attached, when we insert into
foreign partition with batch_size set, buffer refcount leak is detected.

The above example we see a dozen of similar messages:

repro_small.sql:31: WARNING: buffer refcount leak: [14621]
(rel=base/16718/16732, blockNum=54, flags=0x93800000

The issue was introduced in the following commit

commit b676ac443b6a83558d4701b2dd9491c0b37e17c4
Author: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
Date: Fri Jun 11 20:19:48 2021 +0200

Optimize creation of slots for FDW bulk inserts

In this commit we avoid recreating slots for each batch. But it seems
that created slots should still be cleared in the end of
ExecBatchInsert().

At least the attached patch seems to fix the issue.
--
Best regards,
Alexander Pyhalov,
Postgres Professional

Attachment Content-Type Size
repro_small.sql text/plain 1.4 KB
0001-Fix-buffer-refcount-leak.patch text/x-diff 867 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-04-21 10:16:03 Re: buffer refcount leak in foreign batch insert code
Previous Message Jelte Fennema 2023-04-21 09:41:50 Re: Reorder connection markers in libpq TAP tests