Regression in pipeline mode in libpq 14.5

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Regression in pipeline mode in libpq 14.5
Date: 2022-08-14 14:26:43
Message-ID: CA+mi_8ZGSQNmW6-mk_iSR4JZB_LJ4ww3suOF+1vGNs3MrLsv4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

I believe that pipeline mode was broken in libpq 14.5, likely after
the refactoring performed to solve the problem of the unexpected Close
messages sent on PQexecQuery [1].

The psycopg 3.1 test suite hangs when running with libpq 14.5
(reported at [2]). I have written a script to reproduce the issue,
which can be executed running:

```
git clone -b fix-350 git(at)github(dot)com:psycopg/psycopg.git
cd psycopg
python3 -m venv .venv
source .venv/bin/activate
pip install -e ./psycopg
PSYCOPG_IMPL=debug python ./test-350.py
```

The script prints on stderr all the libpq calls and the be-fe trace.
You can find attached the two logs obtained running the script with
libpq 14.4 and 14.5. Differences can be seen online in [3].

The script runs, in Python:
```
with conn.cursor() as cur:
with conn.pipeline() as p:
cur.execute("SELECT 1")
```

The execute() runs an implicit BEGIN, which is also executed in
pipeline mode. Exiting the pipeline() block causes a Sync. So we
expect 3 results in the pipeline (a COMMAND_OK after BEGIN, a
TUPLES_OK after SELECT, a PIPELINE_SYNC). At a glance I see the
following behaviours in 14.5 which seem errors:

- the result of the SELECT (TUPLES_OK) is lost.
- later, a PQisBusy() returns 1, but the following epoll() call blocks
and times out, nothing is received from the network.

Happy to know if we need to do something different to accommodate
changes in 14.5, however these seem regressions to me.

Thank you very much

-- Daniele

[1] https://www.postgresql.org/message-id/CA%2Bmi_8bvD0_CW3sumgwPvWdNzXY32itoG_16tDYRu_1S2gV2iw%40mail.gmail.com
[2] https://github.com/psycopg/psycopg/issues/350
[3] https://www.diffchecker.com/oe0yA6lu

Attachment Content-Type Size
pipeline-14.5.log application/octet-stream 1.8 KB
pipeline-14.4.log application/octet-stream 2.5 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Devrim Gündüz 2022-08-14 14:27:05 Re: BUG #17582: Error: Package: gdal-libs-1.11.4-12.rhel7.x86_64 (@pgdg11)
Previous Message Tom Lane 2022-08-14 14:25:32 Re: BUG #17584: SQL crashes PostgreSQL when using ICU collation