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 1lBTLl-0005Ju-GE for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2021 02:10:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lBTLk-0000gV-Dc for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2021 02:10:56 +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 1lBTLj-0000gN-UW for pgsql-hackers@lists.postgresql.org; Mon, 15 Feb 2021 02:10:56 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lBTLh-0000cc-4U for pgsql-hackers@lists.postgresql.org; Mon, 15 Feb 2021 02:10:54 +0000 Received: by mail-io1-xd31.google.com with SMTP id y5so1546536ioc.2 for ; Sun, 14 Feb 2021 18:10:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PAA2k5gPnIiZ8/Id6wW5Qdt548vGRF0tSfZqh04+mss=; b=0AHirYjaTfa+42XvFB+648bTgb39Pwm05LfoiQB5w6NTp5zeSlB6vf5QZiECfxwcjm ZwV3Ph85lrGn+SJXBiCLGnWPksvFYNYdtcz7JNrbl65pE8JuJtkiN8cKmHR3Yp/Bl1jP PLupE7cDJq2RPDGIfMi4Br1SBOHqtr7Uvz/HfbstiN9O02/6dWqUC2bKPq+e8Nnyf+gQ +SCKvOZD5XBtyymLJchk0A23aPCowYXIA1LUMRZe9AMs9BX2OodcGocZE02tlFG5vofg iDYAuvRDPQSxqbXpHk/DrrR4NGNu1wiYkMyUEBvxw3iSCSOHIhtRlot2Yj8bkI7JlpIj 7vbQ== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PAA2k5gPnIiZ8/Id6wW5Qdt548vGRF0tSfZqh04+mss=; b=m0TVVOJV9/ZUGmqV+HLKdoZR4GVyCwa3uHfEf6AKCAhObaRy0ycpPmz+Kb9KDg6RDq 6mdzFv+/U5d+5z8K/5lSH33nQCvcH6E1UrDKfzlAJgiXzVtpOiDS7EkTjB6cNdIYQBea KffTvbQtp0m74bPDBPR0cdxge7yo4Yw8en2savwsSgVaIRTxzWqCuu19fRgbdchQ4H7Y SgD9uFx+GHojAgMdOgIozcU5SsxbmWhdVM6Cg8f4G0U6CrpKnS/6TpcQnMk+6QPhxp4f Ts8543VHsKAUPsvd0K9uPkbyts4n2x5FExSZ8GLuhiTthaRB+EYrPkKw9pBRJ1rPwQKn IC6g== X-Gm-Message-State: AOAM53100DyAd5Yfq8lRYv3/cttFRxQvLED1r+97CybPGDtrGoTIK2h3 u7x6IN6OPjuMMyK/NS4+VkkTDA== X-Google-Smtp-Source: ABdhPJzOmIRTzrLCHIGxW6N+FAY0ZDokfwn06NP5D5VFp497QM0K7moAtscAiK58K8/loskwFIk+Gw== X-Received: by 2002:a02:c498:: with SMTP id t24mr1478jam.28.1613355052270; Sun, 14 Feb 2021 18:10:52 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id h23sm8295350ila.15.2021.02.14.18.10.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Feb 2021 18:10:51 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 60505801070; Sun, 14 Feb 2021 20:10:50 -0600 (CST) Date: Sun, 14 Feb 2021 20:10:50 -0600 From: Justin Pryzby To: Michael Paquier Cc: Alexey Kondratov , Alvaro Herrera , Peter Eisentraut , Masahiko Sawada , Steve Singer , pgsql-hackers@lists.postgresql.org, Robert Haas , Alexander Korotkov , Masahiko Sawada , Jose Luis Tallon Subject: Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly Message-ID: <20210215021050.GA28165@telsasoft.com> References: <20210127213658.GA736@alvherre.pgsql> <55c6c1526b94d2caf54c33262fe00674@postgrespro.ru> <1c506564e2a732ec17790bd8c34f042e@postgrespro.ru> <20210203065342.GX7450@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="azLHFNyN32YCQGCU" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --azLHFNyN32YCQGCU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Feb 04, 2021 at 03:38:39PM +0900, Michael Paquier wrote: > On Wed, Feb 03, 2021 at 07:54:42PM +0900, Michael Paquier wrote: > > Not sure I like that. Here is a proposal: > > "it is recommended to separately use ALTER TABLE ONLY on them so as > > any new partitions attached inherit the new tablespace value." > > So, I have done more work on this stuff today, and applied that as of > c5b2860. > A second thing I have come back to is allow_system_table_mods for > toast relations, and decided to just forbid TABLESPACE if attempting > to use it directly on a system table even if allow_system_table_mods > is true. This was leading to inconsistent behaviors and weirdness in > the concurrent case because all the indexes are processed in series > after building a list. As we want to ignore the move of toast indexes > when moving the indexes of the parent table, this was leading to extra > conditions that are not really worth supporting after thinking about > it. One other issue was the lack of consistency when using pg_global > that was a no-op for the concurrent case but failed in the > non-concurrent case. I have put in place more regression tests for > all that. Isn't this dead code ? postgres=# REINDEX (CONCURRENTLY, TABLESPACE pg_global) TABLE pg_class; ERROR: 0A000: cannot reindex system catalogs concurrently LOCATION: ReindexRelationConcurrently, indexcmds.c:3276 diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 127ba7835d..c77a9b2563 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -3260,73 +3260,66 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params) { if (IsCatalogRelationOid(relationOid)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot reindex system catalogs concurrently"))); ... - if (OidIsValid(params->tablespaceOid) && - IsSystemRelation(heapRelation)) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move system relation \"%s\"", - RelationGetRelationName(heapRelation)))); - @@ -3404,73 +3397,66 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params) if (IsCatalogRelationOid(heapId)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot reindex system catalogs concurrently"))); ... - if (OidIsValid(params->tablespaceOid) && - IsSystemRelation(heapRelation)) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move system relation \"%s\"", - get_rel_name(relationOid)))); - --azLHFNyN32YCQGCU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Dead-code-REINDEX-CONCURRENTLY-TABLESPACE-.-c5b28604.patch" From b4347c18bc732d30295c065ef71edaac65e68fe6 Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Sun, 14 Feb 2021 19:49:52 -0600 Subject: [PATCH] Dead code: REINDEX (CONCURRENTLY, TABLESPACE ..): c5b286047cd698021e57a527215b48865fd4ad4e --- src/backend/commands/indexcmds.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 127ba7835d..c77a9b2563 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -3260,73 +3260,66 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params) { /* * In the case of a relation, find all its indexes including * toast indexes. */ Relation heapRelation; /* Save the list of relation OIDs in private context */ oldcontext = MemoryContextSwitchTo(private_context); /* Track this relation for session locks */ heapRelationIds = lappend_oid(heapRelationIds, relationOid); MemoryContextSwitchTo(oldcontext); if (IsCatalogRelationOid(relationOid)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot reindex system catalogs concurrently"))); /* Open relation to get its indexes */ if ((params->options & REINDEXOPT_MISSING_OK) != 0) { heapRelation = try_table_open(relationOid, ShareUpdateExclusiveLock); /* leave if relation does not exist */ if (!heapRelation) break; } else heapRelation = table_open(relationOid, ShareUpdateExclusiveLock); - if (OidIsValid(params->tablespaceOid) && - IsSystemRelation(heapRelation)) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move system relation \"%s\"", - RelationGetRelationName(heapRelation)))); - /* Add all the valid indexes of relation to list */ foreach(lc, RelationGetIndexList(heapRelation)) { Oid cellOid = lfirst_oid(lc); Relation indexRelation = index_open(cellOid, ShareUpdateExclusiveLock); if (!indexRelation->rd_index->indisvalid) ereport(WARNING, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot reindex invalid index \"%s.%s\" concurrently, skipping", get_namespace_name(get_rel_namespace(cellOid)), get_rel_name(cellOid)))); else if (indexRelation->rd_index->indisexclusion) ereport(WARNING, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot reindex exclusion constraint index \"%s.%s\" concurrently, skipping", get_namespace_name(get_rel_namespace(cellOid)), get_rel_name(cellOid)))); else { ReindexIndexInfo *idx; /* Save the list of relation OIDs in private context */ oldcontext = MemoryContextSwitchTo(private_context); idx = palloc(sizeof(ReindexIndexInfo)); idx->indexId = cellOid; /* other fields set later */ indexIds = lappend(indexIds, idx); MemoryContextSwitchTo(oldcontext); @@ -3404,73 +3397,66 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot reindex system catalogs concurrently"))); /* * Don't allow reindex for an invalid index on TOAST table, as * if rebuilt it would not be possible to drop it. Match * error message in reindex_index(). */ if (IsToastNamespace(get_rel_namespace(relationOid)) && !get_index_isvalid(relationOid)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot reindex invalid index on TOAST table"))); /* * Check if parent relation can be locked and if it exists, * this needs to be done at this stage as the list of indexes * to rebuild is not complete yet, and REINDEXOPT_MISSING_OK * should not be used once all the session locks are taken. */ if ((params->options & REINDEXOPT_MISSING_OK) != 0) { heapRelation = try_table_open(heapId, ShareUpdateExclusiveLock); /* leave if relation does not exist */ if (!heapRelation) break; } else heapRelation = table_open(heapId, ShareUpdateExclusiveLock); - if (OidIsValid(params->tablespaceOid) && - IsSystemRelation(heapRelation)) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move system relation \"%s\"", - get_rel_name(relationOid)))); - table_close(heapRelation, NoLock); /* Save the list of relation OIDs in private context */ oldcontext = MemoryContextSwitchTo(private_context); /* Track the heap relation of this index for session locks */ heapRelationIds = list_make1_oid(heapId); /* * Save the list of relation OIDs in private context. Note * that invalid indexes are allowed here. */ idx = palloc(sizeof(ReindexIndexInfo)); idx->indexId = relationOid; indexIds = lappend(indexIds, idx); /* other fields set later */ MemoryContextSwitchTo(oldcontext); break; } case RELKIND_PARTITIONED_TABLE: case RELKIND_PARTITIONED_INDEX: default: /* Return error if type of relation is not supported */ ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("cannot reindex this type of relation concurrently"))); break; } /* * Definitely no indexes, so leave. Any checks based on -- 2.17.0 --azLHFNyN32YCQGCU--