pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Michael Nolan <htfoot@gmail.com>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Problem with FDW wrapper errors
Date: Tue, 14 Jul 2020 13:04:01 -0700
Message-ID: <dafd1925-ac26-061b-798a-2f1de57a2ef5@aklaver.com> (raw)
In-Reply-To: <CAOzAquL6Fu+6ZfZmu9TEmh4mBgn+QpTYimvqisJKQ-2ddCwWbw@mail.gmail.com>
References: <CAOzAquL6Fu+6ZfZmu9TEmh4mBgn+QpTYimvqisJKQ-2ddCwWbw@mail.gmail.com>

On 7/14/20 10:03 AM, Michael Nolan wrote:
> An application I wrote is being modified by our development team to use 
> a FDW to a remote MySQL table instead of the postgresql table for a query.
> 
> We're getting this error in the logs periodically.  Maybe about once 
> every 50,000 queries:
> 
> 2020-07-14 11:35:22.799 CDT uscf ::1 ERROR:  failed to execute the MySQL 
> query:
>          Prepared statement needs to be re-prepared
> 2020-07-14 11:35:22.799 CDT uscf ::1 STATEMENT:  select memtp, 
> ('2004-12-18'::date-membirthdt)/365.25  as mage from 
> memmast_simulant_ratings where memid = '13036134'
> 
> If I restart it, it usually goes through, but might fail on that query, 
> but using different data.
> 
> Is this possibly due to transient communication issues between the 
> postgresql server and the remote MySQL server


https://www.postgresql.org/docs/12/sql-prepare.html

"Prepared statements only last for the duration of the current database 
session. When the session ends, the prepared statement is forgotten, so 
it must be recreated before being used again. This also means that a 
single prepared statement cannot be used by multiple simultaneous 
database clients; however, each client can create their own prepared 
statement to use. Prepared statements can be manually cleaned up using 
the DEALLOCATE command."


Dropped connections could be an issue per above. You might also explore 
the other conditions in the above.

> 
> If I just trap the error, wait a few seconds and re-issue the query, is 
> that likely to be sufficient?

I'm guessing not, you will need to issue the PREPARE again per the error 
message:

"Prepared statement needs to be re-prepared"

> --
> Mike Nolan
> htfoot@gmail.com <mailto:htfoot@gmail.com>


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (3+ messages)  latest in thread

Message-ID: <dafd1925-ac26-061b-798a-2f1de57a2ef5@aklaver.com>
Permalink:  ../dafd1925-ac26-061b-798a-2f1de57a2ef5@aklaver.com/
Also on:    postgresql.org/message-id/dafd1925-ac26-061b-798a-2f1de57a2ef5@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, htfoot@gmail.com
  Subject: Re: Problem with FDW wrapper errors
  In-Reply-To: <dafd1925-ac26-061b-798a-2f1de57a2ef5@aklaver.com>
  References: <CAOzAquL6Fu+6ZfZmu9TEmh4mBgn+QpTYimvqisJKQ-2ddCwWbw@mail.gmail.com> <dafd1925-ac26-061b-798a-2f1de57a2ef5@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox