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 1rqlvL-00E0Qi-Fm for pgsql-jdbc@arkaria.postgresql.org; Sun, 31 Mar 2024 03:32:00 +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 1rqluK-00BRJI-Mt for pgsql-jdbc@arkaria.postgresql.org; Sun, 31 Mar 2024 03:30:56 +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 1rqluK-00BRJA-C0 for pgsql-jdbc@lists.postgresql.org; Sun, 31 Mar 2024 03:30:56 +0000 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rqluC-007kCn-Az for pgsql-jdbc@lists.postgresql.org; Sun, 31 Mar 2024 03:30:55 +0000 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5a5508007fcso1699021eaf.2 for ; Sat, 30 Mar 2024 20:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711855846; x=1712460646; 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=4O8XiwNbRJqk/+bTi7FErchuhFyLiqNUx2Wm57z1S9g=; b=mPXB+1lPp4OV6yjKo6fMhCMkWM1pAqphy5IRL0URLFDya//opPjGJrqJVtaf4OhtXK eCgzot6AfVuGucIjR95W4KdoW4hltlD1ViROR/dspaMZCro/IlpNsbkMePXByD5kH9MN LM2gyc77L1Kx9g4Mp5zhaOtnWDABVqGI8jKASR3PY4hdX5eNbG2mfwmAATjPYxWL7lRp t4OgCF9oy0tjC9tswRchzRQpt5MEwxhn0KF0CprZLag2rglnlpvQt25UaxtHq85U64f8 gjsVJ/Ereq94Hbn7kZgo1S+fhAgk8wItWpxXEUk4kQ8ypk8/r1UeyOM1Gmk9K4guu2gx TUzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711855846; x=1712460646; 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=4O8XiwNbRJqk/+bTi7FErchuhFyLiqNUx2Wm57z1S9g=; b=R/yZz5lhgDt80o8fSpB+fTKvZpqZCXHb4yVydViMmKJLRUuvnM3lwpUt/m9I2qzoEM EUgreBNXjCGQF2lZNAFDFwC6r93O5oBnmNCLR4k3kXcz5mhKgRUw0YLr1HNXhLi1PMCZ hKuPwuRw5LlM43ADHBS83Rz7ooCS4P0dY6E/JYf8L6wa1ldx3BBlvGpxMd9fGYCSUFck b3zkLPnxQuX3HA7vAhRog9sQs2y9gx5v5XVy4xSRaANb1pAFO6J2bhtKmP20GFBpxf6J NSqcVKbnNFJjsRiw0UKUnxl0ZIF2XZWNRdY3DRssAeIKr63PFKjzsjRm1eLI+ZnrRPKR FVdA== X-Forwarded-Encrypted: i=1; AJvYcCVcJTUy2Q4en2nZQgWWR8m+/uGiSRiYnhCGbh+gYeJJz7jUQfUHPq8vrVK0e5vG/ONtzYhPlIywFziGUjQRXT147N/tKPd/tvD1avxlE9v/ X-Gm-Message-State: AOJu0YwUL5Yzn8O2MOGB4z3PvsCXJ90MlngdVP0U1x/rQg8gPipMde9o t9rlPVuqz6CEiRVC7RjUrzigy+GPK9vxXjcNRkmYPKW3Ph8Qd4ynfNjtoAhJjkM3ROjolgu/RsP Clxv3u3JxAWOe1l6at8tlkeu5k3I= X-Google-Smtp-Source: AGHT+IGAOsZrU/GOS2sj66m+h8EwyWIb3aSU8r5Yi3daB9JyGB0nheuNVmm89cxipGEDp3l7gLmno3j1kqpR1xLW4YY= X-Received: by 2002:a4a:d74a:0:b0:5a2:32fe:b20a with SMTP id h10-20020a4ad74a000000b005a232feb20amr5060538oot.8.1711855846326; Sat, 30 Mar 2024 20:30:46 -0700 (PDT) MIME-Version: 1.0 References: <60ab210d02748b5da813007ab2504606d0fecaa1.camel@cybertec.at> <2950.1711729266@sss.pgh.pa.us> <29759a95d5194d1a5a468e2585e363a313c7d287.camel@cybertec.at> In-Reply-To: <29759a95d5194d1a5a468e2585e363a313c7d287.camel@cybertec.at> From: James Pang Date: Sun, 31 Mar 2024 11:30:35 +0800 Message-ID: Subject: Re: cached plan must not change result type To: Laurenz Albe Cc: Dave Cramer , Tom Lane , pgsql-jdbc@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000a08a1e0614ec7f6c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a08a1e0614ec7f6c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 1) turn off server side prepared statements with prepareThreshold=3D0 with this threshold=3D0, if it's still possible to avoid parsing, planning from Postgresql server side, like set plan_cache_mode=3Dforce_generic_plan or with default "auto" mode. Postgres= ql server can make the plan cached and reused. 2) change varchar(n) to varchar or text, then restart application, so avoid future similar increase varchar(n) changes. it's safe to performance or optimizer ,right? Thanks, James Laurenz Albe =E6=96=BC 2024=E5=B9=B43=E6=9C=8830= =E6=97=A5=E9=80=B1=E5=85=AD =E4=B8=8B=E5=8D=8810:06=E5=AF=AB=E9=81=93=EF=BC= =9A > On Sat, 2024-03-30 at 08:27 -0400, Dave Cramer wrote: > > > On Fri, 29 Mar 2024 at 19:42, James Pang > wrote: > > > > we did DDL "alter table ... alter column increase varchar(512) to > varchar(1024)", > > > > after that done, hours later, new query select on this table still > failed this error. > > > > From this > https://jdbc.postgresql.org/documentation/server-prepare/#re-execution-of= -failed-statements > , > > > > looks like pgjdbc try to handle this exception and retry, but in ou= r > case, it did not happen. > > > > Could you direct me how to make this retry work? > > > > we only want new transactions,queries work that after the DDL > changes. > > > > I think the best option for you is to turn off server side prepared > statements with prepareThreshold=3D0 > > An alternative option is to take downtime for DDL and restart the > application. > Or to chppse the appropriate data type right away: in your case, that wou= ld > have been "text". > > Yours, > Laurenz Albe > --000000000000a08a1e0614ec7f6c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
1) turn off server side prepared statements with prepareTh= reshold=3D0
=C2=A0 =C2=A0 =C2=A0 =C2=A0with this threshold=3D0, if = it's still possible to avoid parsing, planning from Postgresql server s= ide, like set plan_cache_mode=3Dforce_generic_plan or with default "au= to" mode.=C2=A0 Postgresql server can make the plan cached and reused.=

2) change varchar(n) to varchar or text, then res= tart application, so avoid future similar increase varchar(n) changes.
=C2=A0 =C2=A0 =C2=A0 it's safe to performance or optimizer ,right= ?=C2=A0

Thanks,

James

Laurenz Albe <laurenz.albe= @cybertec.at> =E6=96=BC 2024=E5=B9=B43=E6=9C=8830=E6=97=A5=E9=80=B1= =E5=85=AD =E4=B8=8B=E5=8D=8810:06=E5=AF=AB=E9=81=93=EF=BC=9A
On Sat, 2024-03-30 at 08:27 -0= 400, Dave Cramer wrote:
> > On Fri, 29 Mar 2024 at 19:42, James Pang <jamespang886@gmail.com> wrot= e:
> > > we did DDL "alter table ... alter column increase varch= ar(512) to varchar(1024)",
> > > after that done, hours later, new query select on this table= still failed this error.
> > > From this=C2=A0https://jdbc.postgresql.org/documentation/server-prepa= re/#re-execution-of-failed-statements ,
> > > looks like pgjdbc try to handle this exception and retry, bu= t in our case, it did not happen.
> > > Could you direct me how to make this retry work?
> > > we only want new transactions,queries=C2=A0work that after t= he DDL changes.=C2=A0
>
> I think the best option for you is to turn off server side prepared st= atements with prepareThreshold=3D0

An alternative option is to take downtime for DDL and restart the applicati= on.
Or to chppse the appropriate data type right away: in your case, that would=
have been "text".

Yours,
Laurenz Albe
--000000000000a08a1e0614ec7f6c--