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 1whXl1-000Hys-1o for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2026 19:16:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whXkx-008y0U-2Z for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jul 2026 19:16:28 +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 1whXkw-008y0L-2c for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2026 19:16:28 +0000 Received: from fhigh-a3-smtp.messagingengine.com ([103.168.172.154]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1whXks-00000000KUT-3uG2 for pgsql-hackers@lists.postgresql.org; Wed, 08 Jul 2026 19:16:26 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 816A11400083; Wed, 8 Jul 2026 15:16:21 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Wed, 08 Jul 2026 15:16:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm1; t=1783538181; x=1783624581; bh=tUnw3jazqNUGpV3kF2GyNGrCdB6ovx4N iNg4NopZ1/I=; b=nR+lgpv8H8QDnC3DnzYG1abq7TnzFmeNcaOhmEZAlusqAWR7 eF8OJUSgtiUENZLqqO7OaWVWmnuIcL43p7USunKlgP+am/oY84G5MzGK1BcnNAlx LbhHOiDK/o5qTtKZAppbNyg9K7bIZompwlRAoMSt3le2AHOF8Qz2nDu9UKlwOuMi jGQSRecXLfi2rKLHFYUBYO0nO1vq/xNSbF354+vaAbcd9BN5kT+t4H0Ti2/fIMlJ 1G7MtIrWoRB6jI7SmeVox02RtH4bPWHmwpZlvn/vXW3muq3NRo0+bqeuVtjabtLS ZpxWAAR3XTbi571MVE5CGOf2XvkuAoMX6CSbdQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1783538181; x= 1783624581; bh=tUnw3jazqNUGpV3kF2GyNGrCdB6ovx4NiNg4NopZ1/I=; b=Z Q8oIvwhbrIfifbb/L2vJE64Bh9L4axulVfrJYKXnYqNQ77r776svGI0wYglP/6QG yvmXG50/MCdNmWXHQh4Bn9J7FUHU0UsGRzDhm0oE8o2e+sx+Ih02zDMDvXBYcisd j23hV5xEkze7q4kjOEGxtwxDaSXLY0zdMDra12+SuNS1ZNJO2rDQdc3OYFZQS9+G qT3NaOShwNAOfC/ghgc9K2UXa+bKf2nveXr4gEUvpbGHxH5SM3lP3KrnNkd9XQap E5HL4PofFF2lUmPoaiBTLiLPcXv0lFSG6Ef7RoKUIFdwVSsaKXnEO0w9ktZQ3ms7 n+eqNEYbP2we0aqm8u7Sg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFLQKaqBs2T/pI0agljVmk51KyYhpz80MqVvONLQjt8LKxOqkHtgghi8GqaIiEX1T c/g5CXWyDNKalcW5+YcsyCdQVXawRK3zvUXh9hIxBRTOY3FHCX0XnnpfMGgwQAptBtIxvg kO8DDdHx6a64Xhakt4NUEIBF1mL1g6FcYuP4tWjtSMVkR9tvcet4j0eeCun1kVhjijIEbF YY4ALl4+sTY5qBCVucfa1kRwxf1Y0BKXIHbASGmdUDQkyzyICIS1R//8ts/Hjhc2sjRCZh thzjazwE4McOwUuq/hvJs1Tvd9xp3N4uYKP46DD7/3GveEXIUwIRsBrrFVsBQn5ooECgG9 qc2Zicxh3Bc+CjjIaI8+Ud6p/JvqqU8g6GpalELSwL416W5kJdVTKaCVZqwZ5auLK2LXqV omVXnkCn+Uublg/qv/zhSXKIZR6nlMuESeymGIQEIiFFrcdD9XKa2QByintEs0GylDgEtg YdHEBIqlz7iLXn3KpQlN66igSSb1cMWaknQ/cJyxa1LlSKH370c5MN6T4NZWeA+v8QoVNr hojlRkRaLxP8C2bp47J3oM1qP1+aAqYMdTlwUkPJ1ZI589d580yzbkJATcglwA4PbLUCjm aYQSJ5XdU8OXgBFFtCxALhmg5fa0EBbSzVTXHYX9spsw/Ct0QQRrRl6V/MXA X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Jul 2026 15:16:19 -0400 (EDT) Message-ID: <34844e8c-267c-4daf-b1e0-f26059a4a7d3@eisentraut.org> Date: Wed, 8 Jul 2026 21:16:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: libpq: Process buffered SSL read bytes to support records >8kB on async API To: Heikki Linnakangas , solai v , Jacob Champion Cc: Mark Dilger , Andres Freund , Lars Kanis , pgsql-hackers@lists.postgresql.org, Merlin Moncure References: <2039ac58-d3e0-434b-ac1a-2a987f3b4cb1@greiz-reinsdorf.de> <57d1e8b1-d016-4cea-9b60-63cbdb40eb81@iki.fi> <990a4710-fed1-411a-aba4-ddc25825ee48@iki.fi> Content-Language: de-DE, en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 07.07.26 17:58, Heikki Linnakangas wrote: > On 03/07/2026 12:25, Heikki Linnakangas wrote: >> On 14/05/2026 07:32, solai v wrote: >>> Hi, >>> i tested the latest V3 patch series on current postgreSQL HEAD with >>> SSL enabled.The patches applied cleanly,build succeeded,and the >>> server started successfully.I ran the async libpq test repeatedly and >>> also tested large COPY TO STDOUT operations over SSL.I did not >>> observe hangs,crashes,or visible regressions during testing. >> >> Thanks for the testing! >> >> Here's another patch version, with some small comment and commit >> message changes, and I split the changes slightly differently between >> the two patches. End result is otherwise the same. >> >> I plan to commit this in the next few days. > > Committed and backpatched to all supported versions. Thanks everyone! In pqDrainPending(), there is nread = pqsecure_read(conn, conn->inBuffer + conn->inEnd, bytes_pending); conn->inEnd += nread; But pqsecure_read() can return -1 for error. So adding that to conn->inEnd at that point seems wrong. There is error handling in the following code, but this would still kind of corrupt the conn->inEnd value? /* When there are bytes pending, the read function is not supposed to fail */ if (nread != bytes_pending) { libpq_append_conn_error(conn, "drained only %zu of %zd pending bytes in transport buffer", nread, bytes_pending); return -1; } I'm not sure if that comment means that a -1 return cannot happen? Or just that the whole error check should not happen? Also note that the format placeholder for nread is wrong. If you do get a -1, it will print some large unsigned value.