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.94.2) (envelope-from ) id 1uOftv-008eFP-Dm for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Jun 2025 17:03:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uOftt-00BGMl-6B for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Jun 2025 17:03:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uOfts-00BGMd-Tr for pgsql-bugs@lists.postgresql.org; Mon, 09 Jun 2025 17:03:09 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uOftr-0016ez-2b for pgsql-bugs@lists.postgresql.org; Mon, 09 Jun 2025 17:03:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 559H2qGq495421; Mon, 9 Jun 2025 13:02:52 -0400 From: Tom Lane To: Jacob Champion cc: BATBAATAR Dorjpalam , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18907: SSL error: bad length failure during transfer data in pipeline mode with libpq In-reply-to: <474412.1749479193@sss.pgh.pa.us> References: <18907-d41b9bcf6f29edda@postgresql.org> <1055821.1745949960@sss.pgh.pa.us> <1ba0f64a-9f35-4fb4-83b0-6c11a1b88740@gmail.com> <474412.1749479193@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 09 Jun 2025 10:26:33 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <495419.1749488572.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 09 Jun 2025 13:02:52 -0400 Message-ID: <495420.1749488572@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > For a real fix, the narrowest answer would be to not round down > toSend if we are using an SSL connection. I wonder though if > the round-down behavior is of any use with GSSAPI either, or > more generally if it's sensible for anything except a Unix-pipe > connection. Indeed, it looks like we'd better disable the round-down for GSSAPI too, because pg_GSS_write has exactly this same API requirement that caller has to pass at least as much data as last time. Interestingly, we got a report of such a failure with GSSAPI awhile ago, and "fixed" it in commit d053a879b. Apparently the test case we were looking at then did not trigger this specific pattern involving pqFlush followed by pqPutMsgEnd, because that commit did not do anything to prevent this failure pattern. I'm disinclined to revert what d053a879b did, but we'd better remove or update this comment: + * Note: it may seem attractive to report partial write completion on= ce + * we've successfully sent any encrypted packets. However, that can = cause + * problems for callers; notably, pqPutMsgEnd's heuristic to send onl= y + * full 8K blocks interacts badly with such a hack. We won't save mu= ch, + * typically, by letting callers discard data early, so don't risk it= . regards, tom lane