Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1Xq7-00016f-KB for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jul 2021 17:29:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m1Xq6-00018L-I3 for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jul 2021 17:29:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1Xq6-00017u-5P for pgsql-hackers@lists.postgresql.org; Thu, 08 Jul 2021 17:29:30 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m1Xq3-00089l-L5 for pgsql-hackers@lists.postgresql.org; Thu, 08 Jul 2021 17:29:29 +0000 Received: by mail-pg1-x532.google.com with SMTP id s18so6836041pgg.8 for ; Thu, 08 Jul 2021 10:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=8i+2HuySVRJ/WRRbTLPeTo2hG8UOZNKdhkS4id5lrJ4=; b=cF2etIg/BKm2w2uaLCds3FMhWzmYN9ZaTjBCN/V3A08fDcERA7t2y8biy8VnAhlamD GbWdsCfPiAV2Sbix8idyv15NcrLemwTaVduUT+XAMDamet2ipXCwx0z75089xiYS8RoE EQDqvWscrApo63Rxhi6aWd+dK+VAZOg/e6VTWYN4Psnjb1ntPOEwtIDKY4T5n4k5lKMo 3Dlskiy8kHwJ802bhFR3pvb2/jIom3bXjb8AupA2HkkHCXkmHXUSmR2/PRzvfPDWQslj vaNow0YacJ62s0dDNxUA6HbzAOE+C+fgmKJnRxHUHFTG8G9TNbQ0UM/jVdBky3HfMkR7 O4vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=8i+2HuySVRJ/WRRbTLPeTo2hG8UOZNKdhkS4id5lrJ4=; b=H2F09VfLbgf2eNpV9RDrnEFNLwYZnyazoxFRxw2Onsq1E4VjarAU1lJwMQmTXxQ6lg DdnYfsF8NFzExlbtT8eU+wlX1dTI66JfB0LDZydEvuahN3CkoI6OTA9siHJChCdhPMvD Mcj7VJaOhwE+YGY9HFslmpWFhpC5yVwFhTw9nVRqOBpBDM0DGsPnASVuv+zQz0fnrGLy NUIh+zQSMeBiaw9UakIE1NZL5Nc6WoWr6vdH20WdLlg3Oiqpr4XJAvhCIvZCW2J4A4N/ 2czWh2ODshpOzexT6kUB11Vw0bT7hJsNkDqtc9iLyyQg6EpvVGH+7bE6yA9H2BqEL20A 7quw== X-Gm-Message-State: AOAM532qnwAqhG18syD3obS0aPdOjFixoo9TFpjFdoFUcMr06c/MMuhO mr5JehdQlsYiUKje2jv5cPxj2A== X-Google-Smtp-Source: ABdhPJzf68hMTCmtgyIB1BXPWpqE0FujPQUQc6mNa3+hQS/NwVQJXvwAN4fJbCFv718+OIGAcKTuXg== X-Received: by 2002:a63:6444:: with SMTP id y65mr1059443pgb.379.1625765366449; Thu, 08 Jul 2021 10:29:26 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.95]) by smtp.gmail.com with ESMTPSA id g10sm2925403pjv.46.2021.07.08.10.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 10:29:25 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id A0EB32A0999; Thu, 8 Jul 2021 13:29:23 -0400 (-04) Date: Thu, 8 Jul 2021 13:29:23 -0400 From: Alvaro Herrera To: Boris Kolpackov Cc: pgsql-hackers@lists.postgresql.org, Michael Paquier , Andrew Dunstan , Peter Geoghegan Subject: Re: Pipeline mode and PQpipelineSync() Message-ID: <202107081729.osyyji4ewzjk@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Jul-08, Boris Kolpackov wrote: > Alvaro Herrera writes: > > That seems a fair complaint, but I think PQisBusy is doing the right > > thing per its charter. It is documented as "would PQgetResult block?" > > and it is returning correctly that PQgetResult would not block in that > > situation, because no queries are pending. > > Well, that's one way to view it. But in this case one can say that > the entire pipeline is still "busy" since we haven't seen the > PQpipelineSync() call. So maybe we could change the charter only > for this special situation (that is, inside the pipeline)? To be honest, I am hesitant to changing the charter in that way; I fear it may have consequences I don't foresee. I think the workaround is not *that* bad. On the other hand, since we explicitly made PQpipelineSync not mandatory, it would be confusing to say that PQisBusy requires PQpipelineSync to work properly. > But I agree, it may not be worth the trouble and a note in the > documentation may be an acceptable "solution". I'm having a bit of trouble documenting this. I modified the paragraph in the pipeline mode docs to read: PQisBusy, PQconsumeInput, etc operate as normal when processing pipeline results. Note that if no queries are pending receipt of the corresponding results, PQisBusy returns 0. This seems a bit silly/obvious to me, but it may be enlightening to people writing apps to use pipeline mode. Do you find this sufficient? (I tried to add something to the PQisBusy description, but it sounded sillier.) > I am happy to go either way, just let me know what it will be. And > also if the latest patch to libpq that you have shared[1] is still > necessary. > > [1] https://www.postgresql.org/message-id/202107061747.tlss7f2somqf%40alvherre.pgsql Yes, this patch (or some version thereof) is still needed. I didn't test the modified version of your program without it, but my repro definitely misbehaved without it. -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/