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 1k5ycg-0008Sb-EN for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Aug 2020 21:49:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k5ycf-0007xm-Bf for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Aug 2020 21:49:25 +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 1k5ycf-0007xf-0g for pgsql-hackers@lists.postgresql.org; Wed, 12 Aug 2020 21:49:25 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k5ycc-0007BG-B7 for pgsql-hackers@lists.postgresql.org; Wed, 12 Aug 2020 21:49:23 +0000 Received: by mail-qt1-x842.google.com with SMTP id x12so2794423qtp.1 for ; Wed, 12 Aug 2020 14:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=+Kw+7lsF7z5kdLMyZbnAWp3+gLM7xIU3Qijz8MrEIM8=; b=gFTy4mytN2p984m7uDMdIVc/s0fjuQa4HOnt6lQdYy7CdlDHQ4rRes8DKm9IIDp/gY 4d0pl/PdlCZPQg1D6IeDlkPbky4hJKbzIzzjQ0S/7XdEsgz/PYS2au7h7X50RUWNB3DP 4IJfKHVPbh2+iySOtME3KKR1GBt6sMzMsLm7DTtKXEFgUmBfvPwqhroaaAty7yZzraj4 XFX0tV1JJGqIDyqGhRr/ZCt1xP66/lBej2YZTJ08ijevbxxAFsKytY9aAL507rXRx7UV +sqmKGZcHa5k3/0NaCqTpwAB5nIBVQy+1YOdtCqV2BUCYSwZGF+5/1hqPbC2KALKTDEt uomg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=+Kw+7lsF7z5kdLMyZbnAWp3+gLM7xIU3Qijz8MrEIM8=; b=NR1ofZfiunFf5QvXDLAL8sBK4RrkyiwTPuc+NY4WjtbuIsuTwCksWYd+FqP/pOao8m sCPy6SbIqR39Dm3SSsXF/tSZgdGtULMzcJYrO4mHhVb+RTqsTYXXmpypteOICdK0w+N1 4bPb/UAbXlinL0+DQM50yR52t2GLzY5zPa//6jlnOmAwNjGLoWTISutyG8hxuOKRmuap 8mOXSHwEUFh12L03PmFS0fxBY4z8FLzWVTDk9+paQpA3feM2Xa3pn4T9EA2T9wD2xi/l CuxNFKojRMPYOk+iW2rhs6I0PdZMFLfCEHeMAPmXugQae8sDBisTmIRW9JuUkn+mdDN8 46Wg== X-Gm-Message-State: AOAM530CLspZ5WfUTuiAvvxDnhgcxqXgh6FRApsK9w3u3NDzBKMEt6qy MbLcCbHBGkAWN6qA/H90QGg2fz0j+IptAFkrzCQoVudYQfAvJOImRNHL5nWDKG3YMBTvxc0sI2F DqfkulJaBaA9B82XkN6fQce4wwcUBv04e8udK7H9rCHHHb7nZiB5lHBnG+ulOThJ+2cPTb7u1ls GgSHuEqecdzcYhicAC X-Google-Smtp-Source: ABdhPJzUhCdNyOLkbIT8YDm2BWF7gM0LcxOpm2vXuLGzugx687uJXULAU8+dokIAhQvKIetNRg1z3g== X-Received: by 2002:ac8:7751:: with SMTP id g17mr1959482qtu.392.1597268961010; Wed, 12 Aug 2020 14:49:21 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id l13sm3720986qth.77.2020.08.12.14.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2020 14:49:19 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 077982A0D10; Wed, 12 Aug 2020 17:49:18 -0400 (-04) Date: Wed, 12 Aug 2020 17:49:18 -0400 From: Alvaro Herrera To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Dependencies for partitioned indexes are still a mess Message-ID: <20200812214918.GA30353@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="BOKacYhQ+x31HxR3" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3170626.1594842723@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --BOKacYhQ+x31HxR3 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2020-Jul-15, Tom Lane wrote: > Issue #1: "--clean" does not work > > 1. createdb r2 > 2. pg_restore -d r2 regression.dump > 3. pg_restore --clean -d r2 regression.dump > > pg_restore: while PROCESSING TOC: > pg_restore: from TOC entry 6606; 1259 35458 INDEX idxpart32_a_idx postgres > pg_restore: error: could not execute query: ERROR: cannot drop index public.idxpart32_a_idx because index public.idxpart3_a_idx requires it > HINT: You can drop index public.idxpart3_a_idx instead. > Command was: DROP INDEX public.idxpart32_a_idx; I think this problem is just that we're trying to drop a partition index that's not droppable. This seems fixed with just leaving the dropStmt empty, as in the attached. One issue is that if you previously restored only that particular partition and its indexes, but not the ATTACH command that would make it dependent on the parent index, there would not be a DROP command to get rid of it. Do we need to be concerned about that case? I'm inclined to think not. > (There seem to be some other problems as well, but most of the 54 complaints > are related to partitioned indexes/constraints.) In my run of it there's a good dozen remaining problems, all alike: we do DROP TYPE widget CASCADE (which works) followed by DROP FUNCTION public.widget_out(widget), which fails complaining that type widget doesn't exist. But in reality the error is innocuous, since that function was dropped by the DROP TYPE CASCADE anyway. You could say that the same thing is happening with these noisy DROP INDEX of index partitions: the complaints are right in that each partition's DROP INDEX command doesn't actually work, but the indexes are dropped later anyway, so the effect is the same. > Issue #2: parallel restore does not work Looking. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --BOKacYhQ+x31HxR3 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Don-t-dump-DROP-stmts-for-index-partitions.patch" From 8334445705c53bb0abff407ebb92ac67975a5898 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 12 Aug 2020 17:36:37 -0400 Subject: [PATCH] Don't dump DROP stmts for index partitions They would fail to run in --clean mode anyway --- src/bin/pg_dump/pg_dump.c | 14 +++++++++----- src/bin/pg_dump/pg_dump.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 9c8436dde6..42391b0b2c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -16416,7 +16416,8 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo) qindxname); } - appendPQExpBuffer(delq, "DROP INDEX %s;\n", qqindxname); + if (indxinfo->parentidx == InvalidOid) + appendPQExpBuffer(delq, "DROP INDEX %s;\n", qqindxname); if (indxinfo->dobj.dump & DUMP_COMPONENT_DEFINITION) ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId, @@ -16695,10 +16696,13 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) "pg_catalog.pg_class", "INDEX", fmtQualifiedDumpable(indxinfo)); - appendPQExpBuffer(delq, "ALTER %sTABLE ONLY %s ", foreign, - fmtQualifiedDumpable(tbinfo)); - appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n", - fmtId(coninfo->dobj.name)); + if (indxinfo->parentidx == InvalidOid) + { + appendPQExpBuffer(delq, "ALTER %sTABLE ONLY %s ", foreign, + fmtQualifiedDumpable(tbinfo)); + appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n", + fmtId(coninfo->dobj.name)); + } tag = psprintf("%s %s", tbinfo->dobj.name, coninfo->dobj.name); diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index da97b731b1..2f051b83d9 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -368,7 +368,7 @@ typedef struct _indxInfo * contains both key and nonkey attributes */ bool indisclustered; bool indisreplident; - Oid parentidx; /* if partitioned, parent index OID */ + Oid parentidx; /* if a partition, parent index OID */ SimplePtrList partattaches; /* if partitioned, partition attach objects */ /* if there is an associated constraint object, its dumpId: */ -- 2.20.1 --BOKacYhQ+x31HxR3--