Re: buffer refcount leak in foreign batch insert code

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Alexander Pyhalov <a.pyhalov@postgrespro.ru>
Cc: pgsql-hackers@postgresql.org
Date: 2023-04-21T10:16:03Z
Lists: pgsql-hackers
On Fri, Apr 21, 2023 at 01:07:03PM +0300, Alexander Pyhalov wrote:
> 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

Indeed, nice repro!  That's obviously wrong, I'll look into that.
--
Michael

Commits

  1. Fix buffer refcount leak with FDW bulk inserts

  2. Optimize creation of slots for FDW bulk inserts