Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jvR9y-0001hI-CY for pgsql-general@arkaria.postgresql.org; Tue, 14 Jul 2020 20:04:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jvR9x-00052T-9V for pgsql-general@arkaria.postgresql.org; Tue, 14 Jul 2020 20:04:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jvR9v-00052D-Kr for pgsql-general@lists.postgresql.org; Tue, 14 Jul 2020 20:04:13 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jvR9n-0002Hq-Vk for pgsql-general@postgresql.org; Tue, 14 Jul 2020 20:04:10 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id EBF245C007F; Tue, 14 Jul 2020 16:04:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 14 Jul 2020 16:04:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=x sO+rVld0k5ZLrXWVs+m1rjH6Va+T7286IS5Gh6VE+4=; b=TOD/Fot3870cDQW87 zlqyyvwTBMQrsFAH16t437oVJWt/SIU45DuEAVUXLGbsRW78mI23Sdpnu584s1OX S1EwtoJwtLrqc674d2bCRRR7zNvT/z6aWC2fo2m+eqLFjujNGFfZRtsb+0/8SFU+ Vp7M4EuyFLQGxb0HoDh1xPLyP/VCdv1CiylHd5jwN9OApxY5mQ5t8/1+Scl3il4R /+RIfTZrRfY63OFAeHCE99ldo9tYTPvKORrac2LrL6aadTIXV4bbN9ptcGskUhtN vkf7Tswv4D0NEp8jeB3yN8QvQmND5oOkX17qHA1LMR2Sg9N/9t1PyxijYrHmo9C0 4yq2g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=xsO+rVld0k5ZLrXWVs+m1rjH6Va+T7286IS5Gh6VE +4=; b=VcgS5PAI1KGKqOf+EX5JK9Twf/OCYt26s1Moi32Uw3smT8oHtIymCFPED 1B1h18bn7+JIIucJg8mYpCTHXDXDurvDF7/eFZIJoDdSoQlLEkPkvCQIE8hYpvnB NSXvA7x38rTELVbbHQtmbW0d7euU68os7gjkI1Usmnz5tzh/betDkJv2Aa2/b9C/ hqxevx3zzTy8CMnspX27ZOFr1Xpts3PZ35GGZUjf2HNymAYLoqXPkpkLO6ZOQZWR SO27rLP8V1cYAtJd4jMqi5116W/Y3XIEsWw6xYXASHwb4SmJE+e+1mDQMT0ViYDq /Gie33MOlHapiRIkZ6BHGrhbyH7TA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrfedtgddugeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtke ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepuddufeejte evffehgfduhedthfdvteekieeuheefveevudetkeelueehgeduhefhnecuffhomhgrihhn pehpohhsthhgrhgvshhqlhdrohhrghenucfkphepjeehrddujedvrdehrddvfedunecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id 086073280059; Tue, 14 Jul 2020 16:04:01 -0400 (EDT) Subject: Re: Problem with FDW wrapper errors To: Michael Nolan , "pgsql-general@postgresql.org" References: From: Adrian Klaver Message-ID: Date: Tue, 14 Jul 2020 13:04:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 -- Adrian Klaver adrian.klaver@aklaver.com