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 1slyNB-002Jnf-MS for pgsql-general@arkaria.postgresql.org; Wed, 04 Sep 2024 22:21:10 +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 1slyN9-00G7eu-Kn for pgsql-general@arkaria.postgresql.org; Wed, 04 Sep 2024 22:21:08 +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 1slyN8-00G7eP-3a for pgsql-general@lists.postgresql.org; Wed, 04 Sep 2024 22:21:07 +0000 Received: from fout2-smtp.messagingengine.com ([103.168.172.145]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1slyN0-000Be3-5i for pgsql-general@lists.postgresql.org; Wed, 04 Sep 2024 22:21:05 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id B30511380292; Wed, 4 Sep 2024 18:20:55 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Wed, 04 Sep 2024 18:20:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1725488455; x=1725574855; bh=kBbshZmbPuevmlRPqX3RMKVVBIA6ORovNToSZtyt8J0=; b= 9eqQc3Yn23gK6uZiLs0Ri4itLGn0v1ll0SppvhGOt2S/GZVzv3AxWObOTCeuLW3u uyd0vALF8Z6ieLevdqJ0CBPILFcJ22ynP2yzFtaU7fSBwHBibtAGtl7untq50Hl0 8dtfR/iVgBGBAGqOObWQHIYE2OOczG1egH5bBIjfROGNVs6g5pqNWzNYaP9jSlCV jmsyt+B2uMooSVIxSGiyFEMh8XnvQ40EgkZU4ZfnR3F3GtOGAaZF98zZm39cQEN5 KooU5RZJolbgw7YNNP/LapxvdiYGSoK8MXu6j2vazn0O3uOhxSS+upPXu0vxpO5u f9/kfZ34bSVVCaSoWceT2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1725488455; x= 1725574855; bh=kBbshZmbPuevmlRPqX3RMKVVBIA6ORovNToSZtyt8J0=; b=H rNteDHhqDxQrL3cyavYfC212oxRdHX2VOZKGJZUjNzecnCmKSPR5MPmHLEz1beay cg+Y1YGbfC9vbxW84Qy8S4ajG4cFRVOGyFZxSDluF9jy3CdrEeaA6HN1Mm4cE6jO vRKS4l2OwR+aoD+JoxlEPnYZInakUU78cVeNNlPXqWNdUbCNqumeAz6vxXvAdLUv jo/dreX0DpUsn7/i5If+GN9KbAbNiwa/lIjztpJVBVl3vjRhZpjRVjNEx9WTmiyX 2yLFvn56rw8RHaggDXQ8zFqaPDjWZFHmjqV/nI3P+Le33gAyG1sTZ1VtTAzCh2Fm 8g7VATt4/7V2FlI3aMbaw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudehkedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdej necuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrh esrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepuedufeejjefggfdttdeg hefgkeeuveekkeeiteettdekffehiedvtefhveffgeeunecuffhomhgrihhnpehpohhsth hgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmpdhnsg gprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehsrghmkeel rdhgsehgmhgrihhlrdgtohhmpdhrtghpthhtohepuhhsmhgrnhdrkhessghithhnihhnvg drnhgvthdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhs thhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 4 Sep 2024 18:20:54 -0400 (EDT) Message-ID: <61af3fbe-40db-4900-9144-380a5b305c74@aklaver.com> Date: Wed, 4 Sep 2024 15:20:53 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Issue with Restore dump with plpythonu, plpython3u installed on postgres16 To: Sam Son Cc: Muhammad Usman Khan , pgsql-general@lists.postgresql.org References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/4/24 10:46, Sam Son wrote: > Hi Adrian, > > Thanks for your suggestions. I will try your modifications and do > benchmarking. I got to thinking and realized I missed an important part about separating the schema and data restores using the -s and -a arguments. This is best explained here: https://www.postgresql.org/docs/current/app-pgrestore.html --section=sectionname Only restore the named section. The section name can be pre-data, data, or post-data. This option can be specified more than once to select multiple sections. The default is to restore all sections. The data section contains actual table data as well as large-object definitions. Post-data items consist of definitions of indexes, triggers, rules and constraints other than validated check constraints. Pre-data items consist of all other data definition items. With the modification I suggested the -s argument will result in: -s --schema-only Restore only the schema (data definitions), not data, to the extent that schema entries are present in the archive. This option is the inverse of --data-only. It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data. The issue being it includes post-data definitions as in: "Post-data items consist of definitions of indexes, triggers, rules and constraints other than validated check constraints. " That means when you restore the output of pg_restore -a the above items will be in place and will run. Among other things if there are trigger functions using plpython3u and said functions are not Python3 valid they will fail. You might also get warnings like: " pg_dump: warning: there are circular foreign-key constraints on this table: pg_dump: detail: equipment pg_dump: hint: You might not be able to restore the dump without using --disable-triggers or temporarily dropping the constraints. pg_dump: hint: Consider using a full dump instead of a --data-only dump to avoid this problem. " You might be better off using something like: pg_restore ... --section=pre-data -f ddl_defs.sql Search/replace ddl_defs.sql psql ... -f ddl_defs.sql pg_restore ... --section=data pg_restore ... --section=post-data > > Thanks, > Samson G -- Adrian Klaver adrian.klaver@aklaver.com