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 1uZksB-007YJW-Jp for pgpool-general@arkaria.postgresql.org; Thu, 10 Jul 2025 06:35: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 1uZks9-0091wa-GJ for pgpool-general@arkaria.postgresql.org; Thu, 10 Jul 2025 06:35:10 +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.94.2) (envelope-from ) id 1uZks9-0091wT-74 for pgpool-general@lists.postgresql.org; Thu, 10 Jul 2025 06:35:09 +0000 Received: from mail-ua1-x931.google.com ([2607:f8b0:4864:20::931]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uZks7-006nOQ-0s for pgpool-general@lists.postgresql.org; Thu, 10 Jul 2025 06:35:09 +0000 Received: by mail-ua1-x931.google.com with SMTP id a1e0cc1a2514c-87ec5e1cd4aso320571241.0 for ; Wed, 09 Jul 2025 23:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752129304; x=1752734104; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=UATJgBRd4iPjKeXqEMnOkqeK8cSSDs/h6T6d/9UodqM=; b=GpvH2ql0WBu6bDOCRyz4Io1ZRuNNdFvjIS6K9H7Vu+dC1ZG3QAAejVotSY7uONVg6m 49Eu2ix5q5nI76yqIuwYAEPfoetkB+vKyQEiDt96DE1jyOHV6OLoraOg6FC0xwfn5gFy NLRFY/PUcv8m8nZQ0wJb2N87wBBHO5nTfrz/V5BvMEDwpo4RuADildj5Nsm5VN4+7HeH VmfWCiM+N5LIDpfMykQXzWXEqxoydL0KtKqo9+BA2ul6zAzC35fa7EeTSEnw+gh94din OnJ1XsMCZI/IHzbyRE6kKh0b+dcOxCxPdG17t7B4JnAa3JjKXz7qpF6xx6Su6PoiAI9w 1pEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752129304; x=1752734104; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UATJgBRd4iPjKeXqEMnOkqeK8cSSDs/h6T6d/9UodqM=; b=Mtcp0xJN907yJpWUxHhzIx5xll795AHtgXeQgWqi19+SqK8A3SC9SaiGxCKGhWWYaP c6xzEVHozhxljtEKcpKHnxBQli2i5PBXtvr2Nl/W2+Gbu0gzOdVns+M6SjVmMRrU47gO GxbBn2jBL6KtD9cAcG5NvveLjxPhlPotE21YwJPWbHH9sIiDdwv3oJt7xsPg6/z2bdPg 4gIPOTvi4wSOWDcX8bqQoU9FIpir7uiyKT+oH51W8TBY943n9gahup5d+vq328lNzzAj GYci2a5N0KIuvmuUonVhbZL4ecOsq4oMnu/TPL2bx67mJlF6RWilrkfVHGvDQxeqqLwh ir8Q== X-Gm-Message-State: AOJu0YwaEPNiwCe/5W/Xa2bUUIvbRcnA8f6oxZZThpXJciEn2yQeGSY3 crpLGK9sUwjLl0aUMA0+e3b8p1uRrumyQaSGfrjHyNrU6+Y+dqm1p4iUx54Xo8Gqn5kExE7oM6N snkjTPLcNO9Y2jpDsCQsCadnt3Twx/l0= X-Gm-Gg: ASbGncvrtIOt7a3qnTbnAzeOV1e8RFaz+e/KoSCcdzk0OsGPdI13xVK5JVkJG/GwfWy PwaDtHatA3S0DyJf/iM306AJMZynycvrcFI1kq2Pr4Fp6sD/+yvZ8z5iF3mvzSfQcnpcEP8cTxa PWqhzDpsMy9luQ+c5mFW2tXVMHPhKdu1ecm9xsWIANYMS9Xd1zgwF7e1JSaZBzLkVBj9O0KIlfQ 0QDeA== X-Google-Smtp-Source: AGHT+IFB2iRHHX2mliWRs6zPZLnZ8V+qy1hx0fKhXrksjpC9Mf1s6KxpX95eS8R7besvqF4pEbg39xva3B38QXk07S4= X-Received: by 2002:a05:6102:2ad3:b0:4e9:b0d4:1133 with SMTP id ada2fe7eead31-4f62e18c993mr643141137.20.1752129304407; Wed, 09 Jul 2025 23:35:04 -0700 (PDT) MIME-Version: 1.0 References: <20250710.115535.1767264216072187810.ishii@postgresql.org> In-Reply-To: <20250710.115535.1767264216072187810.ishii@postgresql.org> From: Emond Papegaaij Date: Thu, 10 Jul 2025 08:34:53 +0200 X-Gm-Features: Ac12FXzZIETxYpFrCB40PbYd5x-iEZxEJVV1Bf8vBZBO4MEv04A1FIHMiAxJ4rY Message-ID: Subject: Re: FATAL: simple query "BEGIN" arrived before ending an extended query message To: Tatsuo Ishii Cc: pgpool-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000ca352806398d64af" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ca352806398d64af Content-Type: text/plain; charset="UTF-8" > > > The problem however, is that previously the error was only triggered when > > using autosave, which is not a common setup, but now the error is > triggered > > even when using default configuration. This makes it impossible to > combine > > PgJDBC 42.7.6 and up with pgpool-II. I do not know what the plans are on > > this from the side of PostgreSQL and PgJDBC, but I just wanted to raise > > some awareness on this issue here. IMHO PostgreSQL should either > explicitly > > allow this (in which case pgpool-II needs to be fixed) or explicitly > > disallow it (in which case PgJDBC needs to be fixed). > > As far as I know about PostgreSQL's side, Tom Lane said about this: > https://www.postgresql.org/message-id/2069511.1706571615@sss.pgh.pa.us > > > I think it's poor practice, at best. You should end the > > extended-protocol query cycle before invoking simple query. > > > > I'm disinclined to document, or make any promises about, > > what happens if you mix the protocols. > > In my understanding he does not say PostgreSQL explicitely allows this > (mixing extended and simple protocol message). > It's more or less allowed without any errors, but the expected behavior is not clear nor is it documented. It seems libpq even throws an error on the client side when you try to do this: Jelte Fennema-Nio in https://www.postgresql.org/message-id/CAGECzQQ1hs2DU9pmQq18Y%3DqK4nZqhXDVg-sGEa5K01Lj4XMmxw%40mail.gmail.com > I totally agree that it makes sense to throw an error in this case. > Libpq actually throws an error client side when a caller attempts to > do this, but this is something that should be checked server side, > given that the protocol docs specify this: > docs> At completion of each series of extended-query messages, the > frontend should issue a Sync message. > > The current situation > > is no good as we now simply cannot upgrade PgJDBC anymore (and the same > > will be true for all other users of pgpool-II). > > Yeah. > > What I don't understand is, why PgJDBC decided to make it default > (sending simple protocol query after extended query protocl without > sync) even without autosave being set when they update PgJDBC to > 42.7.7. > It wasn't a real decision to make this happen more often. They fixed a bug that caused many queries to be sent using the extended protocol even when explicitly asked for a simple query: https://github.com/pgjdbc/pgjdbc/issues/3724#issuecomment-3051773696 In our case we got sporadic errors. These errors are very hard to reproduce. Some users were not able to login into our application at all, others had no trouble whatsoever and some users got an error every once in a while. Even when tests seem fine, you might get these errors later on. None of our automated tests failed. On our testing environment we've only seen the error twice in a period of 3 weeks. When we moved to production, we triggered the error over 100 times in just 1 day! I would certainly not recommend using PgJDBC 42.7.6 and up when using pgpool. Best regards, Emond --000000000000ca352806398d64af Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> The problem however, is that = previously the error was only triggered when
> using autosave, which is not a common setup, but now the error is trig= gered
> even when using default configuration. This makes it impossible to com= bine
> PgJDBC 42.7.6 and up with pgpool-II. I do not know what the plans are = on
> this from the side of PostgreSQL and PgJDBC, but I just wanted to rais= e
> some awareness on this issue here. IMHO PostgreSQL should either expli= citly
> allow this (in which case pgpool-II needs to be fixed) or explicitly > disallow it (in which case PgJDBC needs to be fixed).

As far as I know about PostgreSQL's side, Tom Lane said about this:
https://www.postgresql.org/mes= sage-id/2069511.1706571615@sss.pgh.pa.us

> I think it's poor practice, at best.=C2=A0 You should end the
> extended-protocol query cycle before invoking simple query.
>
> I'm disinclined to document, or make any promises about,
> what happens if you mix the protocols.

In my understanding he does not say PostgreSQL explicitely allows this
(mixing extended and simple protocol message).

It's more or less allowed without any errors, but the expected = behavior is not clear nor is it documented. It seems libpq even throws an e= rror on the client side when you try to do this:

> I totally agree tha= t it makes sense to throw an error in this case.
> Libpq actually thr= ows an error client side when a caller attempts to
> do this, but thi= s is something that should be checked server side,
> given that the p= rotocol docs specify this:
> docs> At completion of each series of= extended-query messages, the
> frontend should issue a Sync message.=
=C2=A0
>=C2=A0 The current situation
> is no good as we now simply cannot upgrade PgJDBC anymore (and the sam= e
> will be true for all other users of pgpool-II).

Yeah.

What I don't understand is, why PgJDBC decided to make it default
(sending simple protocol query after extended query protocl without
sync) even without autosave being set when they update PgJDBC to
42.7.7.

It wasn't a real decision t= o make this happen more often. They fixed a bug that caused many queries to= be sent using the extended protocol even when explicitly asked for a simpl= e query:=C2=A0https://github.com/pgjdbc/pgjdbc/issues/3724#issuecomme= nt-3051773696

In our case we got sporadic erro= rs. These errors are very hard to reproduce. Some users were not able to lo= gin into our application at all, others had no trouble whatsoever and some = users got an error every once in a while. Even when tests seem fine, you mi= ght get these errors later on. None of our automated tests failed. On our t= esting environment we've only seen the error twice in a period of 3 wee= ks. When we moved to production, we triggered the error over 100 times in j= ust 1 day! I would certainly not recommend using PgJDBC 42.7.6 and up when = using pgpool.

Best regards,
Emond
<= /div>
--000000000000ca352806398d64af--