buffer refcount leak in foreign batch insert code - Mailing list pgsql-hackers

From Alexander Pyhalov
Subject buffer refcount leak in foreign batch insert code
Date
Msg-id b035780a740efd38dc30790c76927255@postgrespro.ru
Whole thread Raw
Responses Re: buffer refcount leak in foreign batch insert code
List 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.vondra@postgresql.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

pgsql-hackers by date:

Previous
From: Jelte Fennema
Date:
Subject: Re: Reorder connection markers in libpq TAP tests
Next
From: Michael Paquier
Date:
Subject: Re: buffer refcount leak in foreign batch insert code