Обсуждение: Pgbench: remove synchronous prepare

Поиск
Список
Период
Сортировка

Pgbench: remove synchronous prepare

От
Dmitrii Bondar
Дата:
Hi, Hackers!

I was testing a connection pooler with pgbench and pgbench froze. I 
checked the traffic and noticed that pgbench just blocks the execution 
while it is waiting the response to the prepare command.

To reproduce the problem, it is enough to run pgbouncer with the session 
pooling mode and use more clients than the pool size. With the pool size 
of 20:

pgbench -h localhost -p 6432 --client=21 --jobs=1 -S -T 1000 -P 1 
postgres --protocol=prepared

Pgbench with the extended protocol flag does not have this issue because 
pgbench sends the whole parse/bind/execute/sync packet sequence at once 
and waits for the result asynchronously. I suggest implementing this 
behavior for the prepared protocol too.

I attached the pgbouncer configuration to reproduce the issue and the 
proposed fix. I prefer to add a new function to libpqfe instead of 
changing the existing behavior or adding a new state to pgbench. 
Although it is largely duplicated code, it looks to be as non-invasive 
as possible. Implementation and naming need to be discussed.


Tests for pgbench passed. I made small changes to the expected output.


Regards,
Dmitrii Bondar.

Вложения

Re: Pgbench: remove synchronous prepare

От
Dmitrii Bondar
Дата:
Add docs, fix a function number.

On 1/27/26 10:34 AM, Dmitrii Bondar wrote:
> Hi, Hackers!
>
> I was testing a connection pooler with pgbench and pgbench froze. I 
> checked the traffic and noticed that pgbench just blocks the execution 
> while it is waiting the response to the prepare command.
>
> To reproduce the problem, it is enough to run pgbouncer with the 
> session pooling mode and use more clients than the pool size. With the 
> pool size of 20:
>
> pgbench -h localhost -p 6432 --client=21 --jobs=1 -S -T 1000 -P 1 
> postgres --protocol=prepared
>
> Pgbench with the extended protocol flag does not have this 
> issue because pgbench sends the whole parse/bind/execute/sync packet 
> sequence at once and waits for the result asynchronously. I suggest 
> implementing this behavior for the prepared protocol too.
>
> I attached the pgbouncer configuration to reproduce the issue and the 
> proposed fix. I prefer to add a new function to libpqfe instead of 
> changing the existing behavior or adding a new state to pgbench. 
> Although it is largely duplicated code, it looks to be as non-invasive 
> as possible. Implementation and naming need to be discussed.
>
>
> Tests for pgbench passed. I made small changes to the expected output.
>
>
> Regards,
> Dmitrii Bondar.
Вложения

Re: Pgbench: remove synchronous prepare

От
Dmitrii Bondar
Дата:
Rebase.

Regards,
Dmitrii Bondar.
Вложения

Re: Pgbench: remove synchronous prepare

От
lakshmi
Дата:


On Mon, Mar 23, 2026 at 11:45 AM Dmitrii Bondar <d.bondar@postgrespro.ru> wrote:
Rebase.

Hi Dmitrii,

I tested the latest patch with PgBouncer in session pooling mode (pool size 20, 21 clients).

Before applying the patch, pgbench got stuck under this setup and eventually hit a query_wait_timeout error.

After applying the patch, pgbench runs smoothly even when clients are queued. I can see continuous progress output and normal throughput (~60k TPS), with no errors or stalls.

The change works well in my testing.

Thanks for the patch!

Regards,
Lakshmi G

Re: Pgbench: remove synchronous prepare

От
Dmitrii Bondar
Дата:

Hi!

Thank you for reviewing my patch! Should I consider your review complete and move the patch to ‘ready for committer’?

On 4/6/26 1:54 PM, lakshmi wrote:


On Mon, Mar 23, 2026 at 11:45 AM Dmitrii Bondar <d.bondar@postgrespro.ru> wrote:
Rebase.

Hi Dmitrii,

I tested the latest patch with PgBouncer in session pooling mode (pool size 20, 21 clients).

Before applying the patch, pgbench got stuck under this setup and eventually hit a query_wait_timeout error.

After applying the patch, pgbench runs smoothly even when clients are queued. I can see continuous progress output and normal throughput (~60k TPS), with no errors or stalls.

The change works well in my testing.

Thanks for the patch!

Regards,
Lakshmi G

Re: Pgbench: remove synchronous prepare

От
lakshmi
Дата:

Hi Dmitrii,

Yes, my review is complete. The patch works well in my testing and resolves the blocking issue without any regressions.

You can move it to 'Ready for Committer.'

Regards,
Lakshmi G



On Thu, Apr 16, 2026 at 12:45 PM Dmitrii Bondar <d.bondar@postgrespro.ru> wrote:

Hi!

Thank you for reviewing my patch! Should I consider your review complete and move the patch to ‘ready for committer’?

On 4/6/26 1:54 PM, lakshmi wrote:


On Mon, Mar 23, 2026 at 11:45 AM Dmitrii Bondar <d.bondar@postgrespro.ru> wrote:
Rebase.

Hi Dmitrii,

I tested the latest patch with PgBouncer in session pooling mode (pool size 20, 21 clients).

Before applying the patch, pgbench got stuck under this setup and eventually hit a query_wait_timeout error.

After applying the patch, pgbench runs smoothly even when clients are queued. I can see continuous progress output and normal throughput (~60k TPS), with no errors or stalls.

The change works well in my testing.

Thanks for the patch!

Regards,
Lakshmi G