Re: BUG #19895: dblink() never returns and spins at 100% CPU when the remote command is COPY ... TO STDOUT;

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, 1165125080(at)qq(dot)com
Subject: Re: BUG #19895: dblink() never returns and spins at 100% CPU when the remote command is COPY ... TO STDOUT;
Date: 2026-11-24 01:29:20
Message-ID: CAHGQGwEtvAEC2R6C4_12FqmwAaxxHujeGxLrtzYq01J-9S93UQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sat, Nov 21, 2026 at 4:12 PM Raja Sai pranav
<rajasaipranav0(at)gmail(dot)com> wrote:
> The attached patch stops both loops at a COPY result,

Thanks for the patch! LGTM. I've attached an updated version (0001)
with minor cleanup and a revised commit message, along with backpatch
versions for older stable branches.

While reviewing the code, I found another pre-existing issue in dblink:
with fail_on_error = false, dblink() could return rows received before
a remote error, although the docs says that no rows are returned in
that case. Patch 0002 fixes this by discarding those rows.

Since this issue also occurs without COPY, I've attached it as
a separate patch.

Thought?

Regards,

--
Fujii Masao

Attachment Content-Type Size
v2-0002-dblink-Discard-accumulated-rows-after-a-remote-er.patch application/octet-stream 3.4 KB
v2-0001-dblink-Fix-infinite-loops-when-a-remote-command-s.patch application/octet-stream 4.9 KB
nocfbot-v2-0001-dblink-Fix-infinite-loops-when-a-remote-command-s-v17-v15.patch application/octet-stream 5.0 KB
nocfbot-v2-0001-dblink-Fix-infinite-loops-when-a-remote-command-s-v18.patch application/octet-stream 4.9 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message shihao zhong 2026-11-24 01:53:22 Re: pg_rewind and hint bits leads to visibility corruption
Previous Message Zsolt Parragi 2026-11-23 23:16:56 Re: BUG #19932: `repack (concurrently)` does not work in `psql` with `AUTOCOMMIT` set to `off`