Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wLSYH-001nD1-1F for pgsql-bugs@arkaria.postgresql.org; Fri, 08 May 2026 21:16:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wLSYF-00B9jA-0c for pgsql-bugs@arkaria.postgresql.org; Fri, 08 May 2026 21:16:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wLSYE-00B9j2-30 for pgsql-bugs@lists.postgresql.org; Fri, 08 May 2026 21:16:02 +0000 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wLSYD-00000001IUr-0Aag for pgsql-bugs@lists.postgresql.org; Fri, 08 May 2026 21:16:02 +0000 Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-50e97863425so22174721cf.0 for ; Fri, 08 May 2026 14:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778274959; cv=none; d=google.com; s=arc-20240605; b=QhxAd58AdNycPO4Fpb4JQ+GFb1g4jytbiB1178+RgfISeeL2+hbEArDp8OMINeCn9G 6gwWBH9vP1eYx7qkJu8HM+Ou+nXjVudccYPsTv49KXh5YbWGkUR6tLxtn5Zt0P5YdFMT vD3mvTPfBIsRj+34WN9kS9L9Pktf93TgnDDUm6ZJppGFx7l2/eStIGW1yMh4Yj6M9jRL B0xOsLhIxdX1czUzs5q6c2Q+5iLdVm+bx/I0XqHGpbnj0s4Xt9Kx2RJbIa6odi2FZ6Oh iGrxj5seWTNQWvOH24nQmfKKMNuGF8ouoeep4HLxtbgJD7Dkm5G85GccaCzQIApTjSGP 3x3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=bUFQcvnHNrjRS7/8xUAelM5mMB+/x24lL76SHUTfpw4=; fh=0zJLpdH9amOTzvxJfnY78nKQIpkGwbo1KHnQsk2NaZ0=; b=MYxeoZMIS/pw32AeNSyMTghIoV8KnIbdBzb+HjBeGFqfItgUY2bhh4Ipwk8gD+WpFt qabA0gH2ZunCBoio85qzMOjrrr1MjCXFA8PzEoX5i+C7/1iy/Q4wUKPWkaO0BkkLBmCK 7h5U1kRdz2VWY8Hypg53zKNSAICEoF0OIh6RD/Qv1G4apNxVKRzm5l27NJmvRi682Cvb lel31vr9LYfuElVdtyrbxlbKUnMk6aR9sfJ1sSczoONiLXNahMjFPZ6XcP3ky74JHbPK B14ggIR2sjQnkH6YL+oUB9iPHO7TK99lPDf3xk395VQR4n1vxe+Gj3ib+zsYFu1kfPXD TjFA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778274959; x=1778879759; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=bUFQcvnHNrjRS7/8xUAelM5mMB+/x24lL76SHUTfpw4=; b=WCAGTZz145BIVVYw2WrCX2CGzIy8mfYkIO6v2dd00l8kDf3etHGkNqGanwC+SV86d0 uW8EDZqpztt3GH0e0a0pgEOcvwZ4abGlyo0IvNcXFYNtLG4zWqx8pwmpJp/smhan/r8I ufAJfPqImbteU4maX1le16Up89d5VQqXaj424meGwlm1VS7DokxRsFkLL6+b3X2scGsO ZWBrUBhnC9qeVPnKNa1xv6RljPXPF0NjcKuVbeIKPXbBWCqCx0Xts9musrTwSsbFRMZT UlVCqYBHiE1zgcHE+M9LTxdzCixTj5TucUWyubNMOWUu2qQY1X3E+t05TH/QSag89iWw 76nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778274959; x=1778879759; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bUFQcvnHNrjRS7/8xUAelM5mMB+/x24lL76SHUTfpw4=; b=ikM2uT3F/Mb92FUGcB2Y15/Vuz9N+LgDeyTN/IPHK34uWvwRS6pREtT+FBwX+qX6Ah Rg/qVJYxU6JoRNYbYaE3Yg4NwJ8/LajYk2TBGNHfMzkGpZS31sXkipBPEz3vRiFr6qwS ttPKLgRUM8WrvnMmCxzMf+o8iCyjDFFdIxK7NH3nZLIVEGZPp1m/bXZi5Mu2lYu+CIvT kLvblJqWUKBku+jcti/TzkHPI7/m18LbfEF3a8T6ej7dgfkxJbA1UFaxOsAJEsxyMn2u JwtwMIM2vdvr7DM04re/9HmNlc9cojCFGsrYAVDTlL39QZ83sNXYtppcXSj6BS7ptzRo cYIg== X-Forwarded-Encrypted: i=1; AFNElJ8/Ro7OAYplAbZpiQmUmHzyMXtMXjP1BWHcfC2XCEPIlGYmUdXJSdSrjWsXE+sCAL/z61g/3XHfztSV@lists.postgresql.org X-Gm-Message-State: AOJu0YwCoJIOWLTx2lV6ZK9r/4+HVcwscXEk7FL3teWfaml1yTwWf+hG MyoZFpqe5h8nrf7uwhR4X2XpgZLW74lWHtFvRFYStjy0vR5/AJPO2M3kDswYrzI4WysR7lHLdWg BsGEMMTcAkz+8q4zAnuBSAuS1xCCHajc= X-Gm-Gg: AeBDietRVcgDM1LlssK8ymjsjIHHlXRR4OvQR+Vv/+XiPLnWJ16t0JQWjtgIwlg9mW4 YLsyHk0ln7TINh/LdGwdhdMXPzE/kLOvQVv20vVrYn8jVB6h5ZjzuZMytOATg6JuE0N9A1yBcPJ i/8jLH5gHb74HagEYQLHXHqNRlQmySKox9VURPWQCdiE6YONh9IYQ204qp26djuzKgR4qX6bGDl XvZ/lvuTnQvXpUDiYgozZWy9auYkt5c3Ikwcg07oc/LRQf5bQhzKh5s1PUl2KNJm2b/g4ddvouH Pd3CzR1zBGIt/Nuc0c168AgYRbDAzxNJO0z/6oYdw8mBFsdDAso3xUDRe6ay6nX+yCooIuK41ZN 8/MFuBA== X-Received: by 2002:a05:622a:598a:b0:50f:b69a:f4b9 with SMTP id d75a77b69052e-51461e38c5cmr208035701cf.27.1778274959158; Fri, 08 May 2026 14:15:59 -0700 (PDT) MIME-Version: 1.0 References: <19473-92f01422b9220412@postgresql.org> In-Reply-To: From: Kirill Reshke Date: Sat, 9 May 2026 02:15:48 +0500 X-Gm-Features: AVHnY4LG_36K2rp2Ez9cGyI6oxI9j1YE5MYVjk6ZH0NdWCunKgwEKgwQcmtaF0g Message-ID: Subject: Re: BUG #19473: regression error in dblink: another command is already in progress To: o15611@gmail.com, pgsql-bugs@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 9 May 2026 at 01:24, Kirill Reshke wrote: > > On Sat, 9 May 2026 at 00:43, PG Bug reporting form > wrote: > > > > The following bug has been logged on the website: > > > > Bug reference: 19473 > > Logged by: Oleg Ivanov > > Email address: o15611@gmail.com > > PostgreSQL version: 18.3 > > Operating system: Linux > > Description: > > > > Testcase: > > SELECT * FROM dblink('dbname=postgres user=postgres', $$ select 7; $$ ) as > > (col1 int); > > SELECT * FROM dblink_connect('connection1', 'host=/var/run/postgresql > > port=5432'); > > SELECT * FROM dblink_send_query('connection1', $$ select 8 from pg_sleep(1); > > $$ ); > > SELECT dblink_is_busy('connection1'); > > SELECT * FROM dblink_get_result('connection1') as t(col1 int); > > --- SELECT dblink_is_busy('connection1'); > > SELECT * FROM dblink_exec('connection1', $$ CHECKPOINT; $$); > > SELECT * FROM dblink_disconnect('connection1'); > > > > col1 > > ------ > > 7 > > (1 row) > > > > dblink_connect > > ---------------- > > OK > > (1 row) > > > > dblink_send_query > > ------------------- > > 1 > > (1 row) > > > > dblink_is_busy > > ---------------- > > 1 > > (1 row) > > > > col1 > > ------ > > 8 > > (1 row) > > > > ERROR: another command is already in progress > > CONTEXT: while executing command on dblink connection named "connection1" > > dblink_disconnect > > ------------------- > > OK > > (1 row) > > > > There was no error in 16 version. The error appeared in 17 version. It > > seems, there is a regression bug. > > The workaround is to uncomment a commented statement. > > > > > > > > > > Hi! Thank you for this report, I was able to reproduce this behaviour. > My git bisect shows that first commit where this errors out is d3c5f37 > > ``` > commit d3c5f37dd543498cc7c678815d3921823beec9e9 (HEAD) > Author: Noah Misch > Date: Mon Jan 8 11:39:56 2024 -0800 > > Make dblink interruptible, via new libpqsrv APIs. > > ``` So, reason is that dblink_get_result calls dblink_record_internal which in turn read data with /* async result retrieval, do it the old way */ PGresult *res = libpqsrv_get_result(conn, dblink_we_get_result); inside, PQgetResult sets connection state to PGASYNC_READY, and then reads all messages from this connection but not the RFQ. this pending RFQ causing issues on any subsequent dblink call with this connection. I have this "funny" fix by the way. Obviously this is dumb, but I think we should do something similar ``` reshke@reshke:~/pg$ git diff diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 19a362526d2..ed3e8023b55 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -812,6 +812,8 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async) } PG_END_TRY(); + Assert(!PQisBusy(conn)); + return (Datum) 0; } ``` -- Best regards, Kirill Reshke