Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jC9Um-0007No-HW for pgsql-general@arkaria.postgresql.org; Wed, 11 Mar 2020 22:06:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jC9Tm-0005UT-Fi for pgsql-general@arkaria.postgresql.org; Wed, 11 Mar 2020 22:05:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jC9Tk-0005SL-D4 for pgsql-general@lists.postgresql.org; Wed, 11 Mar 2020 22:05:30 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jC9Tf-0007so-Js for pgsql-general@postgresql.org; Wed, 11 Mar 2020 22:05:27 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E9D4921E50; Wed, 11 Mar 2020 18:05:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 11 Mar 2020 18:05:20 -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=fm2; bh=O MIfE4iRqz0Quc6oXcjQgiMr4BQCse3AY+8SLXfE6Z0=; b=cILzSiHoPkopca/M5 YzCLWQoGrqGd8BajyL0Uyn5QGJt2Tfk2fqv1A6DcJX6R8EhLTh/ECYgS+J3UbMZQ /MCgcDp3F3dijK0VGNucJkqd8fkcmK0ICqej/nVgQfAmeGKkKysed1VxGuwxr0Vp 7j4OHBwJ7T3e2kqY8L1kalvcoGEpMqxjW3MQ4RRCZ3SVJ/wkjpTip25M9BqVxzwA JuF3suU5KvlYBGxIFKKv3V1opLwTv1pcuEuS9oBjTkMZM4J3fQmciblfJAuZ27Ll mmcoQZHsmOUs8+bs2q9vDHvReVviz7WAJcs6CheOvVjQxUCVbaSM04hT9Ii0wyjT 7w9dQ== 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=fm2; bh=OMIfE4iRqz0Quc6oXcjQgiMr4BQCse3AY+8SLXfE6 Z0=; b=RA2ozgTXll0BIiTcZAtBcBPahbfI/Glpr3CdIn0Bwap0gipuw/6MxQjqd dYT3gfYgy0g7aZxdaYEOZKvUlOPnBC233zU5xjyBuwKmit1B05KYTPfcweSFwabb epS4YO50CMFgr6nLOq1hhPsJaTrI1wDWpZQI7nWO/8zfErKIDVVYogUQ9rJxCrVN UKnV056boXDRxcOg9Ajec62VrYyFlBm3/RiJp+4vvlMVMpsOSKo8AW4JgDRlIXxF j3XODHuJvvO5BGxyjNYCstnh9vsFZ92lysCk4CPZzo3UX84Z6dqQJhd4R8h4syV2 nNzWG3dCcqe8QGl+weBgD63edO/Fg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedruddvgedgtdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepjedurddvuddvrdduvdelrdduleefnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklh grvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id C632B3060F09; Wed, 11 Mar 2020 18:05:19 -0400 (EDT) Subject: Re: pg_restore restores out of order To: Kevin Brannen , "pgsql-general@postgresql.org" References: From: Adrian Klaver Message-ID: <0e314bd5-5611-e70f-eb4a-c3c2a5fe232f@aklaver.com> Date: Wed, 11 Mar 2020 15:05:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/11/20 2:46 PM, Kevin Brannen wrote: > I'm working thru our system to upgrade from 9.6.5 to 12.2. One of the last things I'm verifying is backup/restore and it's failing for no reason I can figure out. So I'm looking for pointers on this. > > If it matters, the code is from the version 12.2 from the Pg site, RPMs for Centos 6 (.10). > > The backup is made like: > > # $PGPATH/pg_dump --format=d --jobs=2 --file=$exp --dbname=nms --schema=public Which version of pg_dump 9.6.5 or 12.2? More below. > > As far as I can tell, it worked well as the result is about the right size, exit code was at least 0. I then go change a couple of things so I know if the restore works or not (i.e. they should disappear). > > Restore looks something like: > > # cd $exp > # echo " > ALTER SCHEMA public RENAME TO savepublic; > CREATE SCHEMA public AUTHORIZATION nmsroot; > " | $PGPATH/psql -d nms > # /usr/pgsql-12/bin/pg_restore --jobs=2 --dbname=nms --schema=public . > > So we move the current schema to the side just in case something goes wrong and we need to move it back, create an empty schema for it, then restore into that schema. Then it goes bad... > > pg_restore: while PROCESSING TOC: > pg_restore: from TOC entry 6356; 0 23653 TABLE DATA subscribers nmsroot > pg_restore: error: COPY failed for table "subscribers": ERROR: relation "su_profiles" does not exist > LINE 1: SELECT srvc_data FROM su_profiles WHERE su_profile... > ^ > QUERY: SELECT srvc_data FROM su_profiles WHERE su_profile_pk = p_profile_fk > CONTEXT: PL/pgSQL function public.check_data_ip(integer,integer,character varying) line 7 at SQL statement > COPY subscribers, line 1: "61 1002 \N SU_1002 t \N 4 \N 1 250 0 2015-06-22 16:56:27.79333+00 nmsmgr \N \N \N" What is in public.check_data_ip(integer,integer,character varying)? Is it a trigger function on subscribers? > > And it goes further downhill with missing FK's, etc in other tables later because of the missing data. The exit code is definitely not 0. > > I've tried removing the "--jobs=2" so it'll go single threaded -- it still fails. I also did a new dump with the default plain text dump, and the restore with that also failed in the same way. Checking out the backup itself, I get: > > # pg_restore -Fd . --list | egrep 'su_profile|subscriber' > k1 > > 254; 1259 23653 TABLE public subscribers nmsroot > 335; 1259 24222 TABLE public su_profiles nmsroot > 5442; 2604 18650 DEFAULT public su_profiles su_profile_pk nmsroot > 5303; 2604 18651 DEFAULT public subscribers subscriber_pk nmsroot > 6437; 0 24222 TABLE DATA public su_profiles nmsroot > 6356; 0 23653 TABLE DATA public subscribers nmsroot > ....... constraints, index, triggers, FK -- down here > > I've removed FUNCTIONS, VIEWS, & SEQ objects from the list. That list is in order that is in the file. I suppose creating the tables in that order is fine, but there is a FK constraint in subscribers pointing to su_profiles, so that order does worry me a little, except all the FK stuff is after the data load so I really should be fine. The data looks like it'll be in the right order (at least for --jobs=1, yet that failed too). > > I don't see anything extra in the Pg error log either. > > I don't think I'm running into any issues with "other DB objects being missing". Looking at the release notes, I see there were some changes for 12.1 with parallel restores, but I can't tell if that's affecting me or not. I know that the public schema & search_path changed for dump & restore in 10.3, but this doesn't look like that's a problem here. I've reread the doc pages on pg_dump and pg_restore and don't see anything that look like it'd be bad for me. > > Can anyone see anything that looks wrong? Suggest something else to try or look at? > > Kevin > This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain confidential information. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, distribution, review, copy or use of any of the information contained in or attached to this message is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately notify us by reply e-mail, and destroy the original transmission and its attachments without reading them or saving them to disk. Thank you. > > -- Adrian Klaver adrian.klaver@aklaver.com