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.89) (envelope-from ) id 1i62Dq-0004MV-9M for pgsql-general@arkaria.postgresql.org; Fri, 06 Sep 2019 00:35:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i62Do-0005MD-Rl for pgsql-general@arkaria.postgresql.org; Fri, 06 Sep 2019 00:35:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i62Dn-0005Jo-6P for pgsql-general@lists.postgresql.org; Fri, 06 Sep 2019 00:35:28 +0000 Received: from [66.111.4.29] (helo=out5-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i62Dj-0005vY-T3 for pgsql-general@postgresql.org; Fri, 06 Sep 2019 00:35:26 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 1205B21FD7; Thu, 5 Sep 2019 20:35:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 05 Sep 2019 20:35:13 -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=G t8F5x2ePJ3z+uSaFN4brBG2awWiajr2SaS1GDXmViM=; b=K7ZzoyU7sJapRrXCG eDJGDR/iByP9aHCpoKyRw/Ipmj42Sqjc2l+4cRSxIshQTcSYICX73DNrBs2tuveG pqdgdK0H19Ym+vMqIXPLtRpf8aFnkAu9VFmJKByGWuW22IllKpfMaP7aaWqt8osI 9kPMbnzNgkRCKIpnoxQ7HY8JZP+9IacsYQybUbl8RIGpe5OGh25q83bMw7N+hqIW A94It60A50wtlbhthAO2+9rK6CJtFwgHkClpoqV0eTKnR0CqwFqvjqRMuJ4EP629 XzsRIP6+cuPNAmrBeF8aaO4BGjqoUPRkVF/0ymhPaQzQZtJN7otdG2w9DMsuXQLk Q5Vdw== 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=Gt8F5x2ePJ3z+uSaFN4brBG2awWiajr2SaS1GDXmV iM=; b=b9bSbqBWwy8ZLBIZRmr7nRIQTjWXhWe7FG9queGFoGkkLJaAKpByHeKwi bMeVVGsvNSGG69bz2jj5aSEsLRp6Y8k4eNyrrDskR+CRPyUAaU8zBu6/K9PZ/ghE 7lLxT7wj7HgNIYPcaVqQhI6wCcv9h2yQK8WDHvhXI3dEtBJCji/NpIBlcLsfAyAz /WHlm1FlqRulT617siH9e0y8L3e1Dl/5q36/QpjJ7D5PYgFxqft8V5txjcbXbA6f ulyqBLM2kOaI6rdEo0aDf3WHwrcA9svMN8ei6dJhx8tKyq+7hA52kbQYHhwf+pUM dxFCxNxcstOEtC79Hz52RVkmWTWIg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudejkedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepjedurddvuddvrdduhedtrddvtddvnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsth gvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 3B66580061; Thu, 5 Sep 2019 20:35:12 -0400 (EDT) Subject: Re: pg_restore issues with intarray To: Kevin Brannen , "pgsql-general@postgresql.org" References: <587d9b02-e4c4-c08e-4b70-169d029bd3e7@aklaver.com> <804d3055-b371-d914-7a77-1b9d8cf703cf@aklaver.com> From: Adrian Klaver Message-ID: <0e059013-15d7-b586-db9f-5ccd653b0689@aklaver.com> Date: Thu, 5 Sep 2019 17:35:11 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.29 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/5/19 5:05 PM, Kevin Brannen wrote: >> On 9/5/19 4:24 PM, Adrian Klaver wrote: >>> On 9/5/19 4:06 PM, Kevin Brannen wrote: >>>>> From: Adrian Klaver >>>>> >>>>> On 9/5/19 2:57 PM, Kevin Brannen wrote: >>>>>> I think I need some help to understand what’s going here because I >>>>>> can’t figure it out and google isn’t helping. >>>>>> >>>>>> This is for Pg 9.6.5. (Yes, we are upgrading to 12.x in a few >>>>>> months, or so the plan is.) Pg code came from the community and we >>>>>> compiled it with no changes. This is on Centos 6.7, though I think >>>>>> the OS doesn’t matter. >>>>>> >>>>>> We’re calling pg_restore like: >>>>>> >>>>>> $PGPATH/pg_restore -jobs=$NCPU --dbname=x . >>>>>> >>>>>> FWIW, the backup was created with: >>>>>> >>>>>> $PGPATH/pg_dump --clean --create --format=d --jobs=$NCPU >>>>>> --file=$EXP --dbname=x >>>>> >>>>> The options you are adding for --clean, --create only have meaning >>>>> for plain text dumps. If you want those actions to occur on the >>>>> restore then add them to the pg_restore line. Though if you are >>>>> going to create a new database it will inherit objects from >>>>> template1(as you found below), assuming you have not set WITH >>>>> TEMPLATE to something else. >>>>> >>>> >>>> Good point that I'm not doing plain text dumps. >>>> >>>> Are you saying that my problem is that I need "--clean" on the >>>> pg_restore? > > Not the issue, that made various things worse. :) > >> No, just that if you were expecting the clean to happen on the >> restore you would be disappointed. > > To be crystal clear, on restore I do this from a bash script: > > # move old to the side in case we need this on failure > $PGPATH/psql -d template1 -c "DROP DATABASE IF EXISTS save$db;" > $PGPATH/psql -d template1 -c "ALTER DATABASE $db RENAME TO save$db;" > # restore > $PGPATH/createdb -e -O $dbowner -T template0 $db > $PGPATH/pg_restore $VERBOSE --jobs=$NCPU --dbname=$db . > > So by using template0, I'm expecting nothing to be there and the restore > to put everything in there I need to get back to the point where the > backup/dump happened. This is why I'm surprised I'm getting this error. > > It feels like the restore is adding the intarray extension, which does a > CREATE OPERATOR FAMILY on its own, then later the restore does CREATE OPERATOR > FAMILY on again causing the problem. Yet this doesn't happen on most of our > databases, just a few. It's maddening to me. > >>>> I can try that. The fact that this only happens on a few DBs and not >>>> all still mystifies me. See below on the template.. >> >> My guess is you where restoring into a database with preexisting >> objects because neither create or clean was being done. > > Shouldn't be happening with that createdb command. Hmm, I wonder what > I'd see if I put a "psql" command with "\dx" after the createdb and before > the restore... What does \dx show in the database you taking the dump from? > > Nope, the only extension is plpgsql, so the problem is coming from the > restore. Maybe I gave a bad option to pg_dump, but pg_restore seems to be > the issue. It really makes me want to modify the toc.dat file and hack > out those CREATE OPERATOR FAMILY lines and see what happens. What if you do a restore to a file only the schema e.g.: pg_restore -s -f some_file.sql This will create a plain text version of only the schema objects in some_file.sql instead of restoring to the database. It might help shed some light. > > K. -- Adrian Klaver adrian.klaver@aklaver.com