Thread: Re: Some read stream improvements

Re: Some read stream improvements

From
Andres Freund
Date:
Hi,

On 2025-02-17 17:55:09 +1300, Thomas Munro wrote:
> 0004-Respect-pin-limits-accurately-in-read_stream.c.patch
> 
> The current coding only computes the remaining "fair share" of the
> buffer pool for this backend at stream initialisation.  It's hard, but
> not impossible, to get one backend to pin more than 1/max_connections
> of the buffer pool (the intended cap), when using multiple streams at
> the same time in one backend.  This patch moves the time of check to
> the time of use, so it respects the limit strictly.  I avoid adding
> any changes to the fast path for all-cached streams, which only pin
> one buffer at a time.

I was working on expanding tests for AIO and as part of that wrote a test for
temp tables -- our coverage is fairly awful, there were many times during AIO
development where I knew I had trivially reachable temp table specific bugs
but all tests passed.

The test for that does trigger the problem described above and is fixed by the
patches in this thread (which I included in the other thread):

https://postgr.es/m/knr4aazlaa4nj3xnpe4tu6plwayovzxhmteatcpry2j6a6kc4v%40aonkl53s2ecs

Just linked instead of attached to not trigger cfbot.

Greetings,

Andres Freund