agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH 4/5] ReindexPartitions() to set indisvalid.. 394+ messages / 2 participants [nested] [flat]
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH 4/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index e54314e9a4..99508b0d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1652,8 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1663,9 +1661,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3107,6 +3102,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --dTy3Mrz/UPE2dbVg-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f4d49f5bf6..77390f0c1e 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1608,8 +1608,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1620,9 +1618,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2924,6 +2919,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --i3lJ51RuaGWuFYNw-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ffc166206b..c6a75e887f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1628,8 +1628,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1640,9 +1638,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) */ ReindexPartitions(indexRelationId, REINDEXOPT_CONCURRENTLY | REINDEXOPT_SKIPVALID, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -2944,6 +2939,24 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) */ ReindexMultipleInternal(partitions, options); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --cWoXeonUoKmBZSoM-- ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 89c2f62eda..739bd14001 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1641,8 +1641,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1652,9 +1650,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3034,6 +3029,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --MfFXiAuoTsnnDAfZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0004-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. @ 2020-10-31 04:52 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Justin Pryzby @ 2020-10-31 04:52 UTC (permalink / raw) Something like this should probably have been included in a6642b3ae060976b42830b7dc8f29ec190ab05e4 See also 71a05b223, which mentioned the absence of any way to validate an index. --- src/backend/commands/indexcmds.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 10d4da136f..b21555b6cf 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1643,8 +1643,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * CIC needs to mark a partitioned index as VALID, which itself * requires setting READY, which is unset for CIC (even though * it's meaningless for an index without storage). - * This must be done only while holding a lock which precludes adding - * partitions. */ CommandCounterIncrement(); index_set_state_flags(indexRelationId, INDEX_CREATE_SET_READY); @@ -1654,9 +1652,6 @@ reindex_invalid_child_indexes(Oid indexRelationId) * this commits and then starts a new transaction immediately. */ ReindexPartitions(indexRelationId, ¶ms, true); - - CommandCounterIncrement(); - index_set_state_flags(indexRelationId, INDEX_CREATE_SET_VALID); } /* @@ -3098,6 +3093,24 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel) */ ReindexMultipleInternal(partitions, params); + /* + * If indexes exist on all of the partitioned table's children, and we + * just reindexed them, then we know they're valid, and so can mark the + * parent index as valid. + * This handles the case of CREATE INDEX CONCURRENTLY. + * See also: validatePartitionedIndex(). + */ + if (get_rel_relkind(relid) == RELKIND_PARTITIONED_INDEX + && !get_index_isvalid(relid)) + { + Oid tableoid = IndexGetRelation(relid, false); + List *child_tables = find_all_inheritors(tableoid, ShareLock, NULL); + + /* Both lists include their parent relation as well as any intermediate partitioned rels */ + if (list_length(inhoids) == list_length(child_tables)) + index_set_state_flags(relid, INDEX_CREATE_SET_VALID); + } + /* * Clean up working storage --- note we must do this after * StartTransactionCommand, else we might be trying to delete the active -- 2.17.0 --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v13-0005-Refactor-to-allow-reindexing-all-index-partition.patch" ^ permalink raw reply [nested|flat] 394+ messages in thread
* [PATCH v1] Cleanup explicit PREPARE query strings @ 2025-12-24 14:31 Julien Rouhaud <[email protected]> 0 siblings, 0 replies; 394+ messages in thread From: Julien Rouhaud @ 2025-12-24 14:31 UTC (permalink / raw) When a multi statements query string contains one PREPARE statement (or multiple), the whole query string was saved in the cached plan. This is wasteful as that string can be artitrarily big, but it can also confusing as some other parts like pg_prepared_statements will output the saved query string as-is. This commit changes this behavior and only stores the part of the query string that correspond to any given PREPARED statement, similarly to how it's already done in pg_stat_statements. --- contrib/auto_explain/t/001_auto_explain.pl | 8 ++-- src/backend/commands/prepare.c | 43 +++++++++++++++++++-- src/test/regress/expected/prepare.out | 44 +++++++++++++--------- src/test/regress/sql/prepare.sql | 2 +- 4 files changed, 72 insertions(+), 25 deletions(-) diff --git a/contrib/auto_explain/t/001_auto_explain.pl b/contrib/auto_explain/t/001_auto_explain.pl index 6af5ac1da18..535c4770095 100644 --- a/contrib/auto_explain/t/001_auto_explain.pl +++ b/contrib/auto_explain/t/001_auto_explain.pl @@ -60,7 +60,7 @@ $log_contents = query_log($node, like( $log_contents, - qr/Query Text: PREPARE get_proc\(name\) AS SELECT \* FROM pg_proc WHERE proname = \$1;/, + qr/Query Text: PREPARE get_proc\(name\) AS SELECT \* FROM pg_proc WHERE proname = \$1/, "prepared query text logged, text mode"); like( @@ -82,7 +82,7 @@ $log_contents = query_log( like( $log_contents, - qr/Query Text: PREPARE get_type\(name\) AS SELECT \* FROM pg_type WHERE typname = \$1;/, + qr/Query Text: PREPARE get_type\(name\) AS SELECT \* FROM pg_type WHERE typname = \$1/, "prepared query text logged, text mode"); like( @@ -98,7 +98,7 @@ $log_contents = query_log( like( $log_contents, - qr/Query Text: PREPARE get_type\(name\) AS SELECT \* FROM pg_type WHERE typname = \$1;/, + qr/Query Text: PREPARE get_type\(name\) AS SELECT \* FROM pg_type WHERE typname = \$1/, "prepared query text logged, text mode"); unlike( @@ -164,7 +164,7 @@ $log_contents = query_log( like( $log_contents, - qr/"Query Text": "PREPARE get_class\(name\) AS SELECT \* FROM pg_class WHERE relname = \$1;"/, + qr/"Query Text": "PREPARE get_class\(name\) AS SELECT \* FROM pg_class WHERE relname = \$1"/, "prepared query text logged, json mode"); like( diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 34b6410d6a2..11b330ab73d 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -27,6 +27,7 @@ #include "commands/prepare.h" #include "funcapi.h" #include "nodes/nodeFuncs.h" +#include "nodes/queryjumble.h" #include "parser/parse_coerce.h" #include "parser/parse_collate.h" #include "parser/parse_expr.h" @@ -64,6 +65,7 @@ PrepareQuery(ParseState *pstate, PrepareStmt *stmt, Oid *argtypes = NULL; int nargs; List *query_list; + const char *new_query; /* * Disallow empty-string statement name (conflicts with protocol-level @@ -80,14 +82,49 @@ PrepareQuery(ParseState *pstate, PrepareStmt *stmt, */ rawstmt = makeNode(RawStmt); rawstmt->stmt = stmt->query; - rawstmt->stmt_location = stmt_location; - rawstmt->stmt_len = stmt_len; + + /* + * Extract the query text if possible. + * + * If we have a statement location, we can extract the relevant part of the + * possibly multi-statement query string. If not just use what we were + * given. + */ + if (stmt_location < 0) + { + rawstmt->stmt_location = stmt_location; + rawstmt->stmt_len = stmt_len; + new_query = pstate->p_sourcetext; + } + else + { + const char *cleaned; + char *tmp; + + rawstmt->stmt_len = stmt_len; + cleaned = CleanQuerytext(pstate->p_sourcetext, &stmt_location, + &rawstmt->stmt_len); + + if (rawstmt->stmt_len == 0) + rawstmt->stmt_len = strlen(cleaned); + + /* + * CleanQuerytext() removes any leading whitespace and returns a + * pointer to the first actual character, so the cleaned query string + * is guaranteed to start at offset 0. + */ + rawstmt->stmt_location = 0; + tmp = palloc(rawstmt->stmt_len + 1); + strlcpy(tmp, cleaned, rawstmt->stmt_len + 1); + + new_query = tmp; + } /* * Create the CachedPlanSource before we do parse analysis, since it needs * to see the unmodified raw parse tree. */ - plansource = CreateCachedPlan(rawstmt, pstate->p_sourcetext, + plansource = CreateCachedPlan(rawstmt, new_query, CreateCommandTag(stmt->query)); /* Transform list of TypeNames to array of type OIDs */ diff --git a/src/test/regress/expected/prepare.out b/src/test/regress/expected/prepare.out index 5815e17b39c..c645a4e5d0e 100644 --- a/src/test/regress/expected/prepare.out +++ b/src/test/regress/expected/prepare.out @@ -6,7 +6,17 @@ SELECT name, statement, parameter_types, result_types FROM pg_prepared_statement ------+-----------+-----------------+-------------- (0 rows) -PREPARE q1 AS SELECT 1 AS a; +SELECT 'bingo'\; PREPARE q1 AS SELECT 1 AS a \; SELECT 42; + ?column? +---------- + bingo +(1 row) + + ?column? +---------- + 42 +(1 row) + EXECUTE q1; a --- @@ -14,9 +24,9 @@ EXECUTE q1; (1 row) SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements; - name | statement | parameter_types | result_types -------+------------------------------+-----------------+-------------- - q1 | PREPARE q1 AS SELECT 1 AS a; | {} | {integer} + name | statement | parameter_types | result_types +------+-----------------------------+-----------------+-------------- + q1 | PREPARE q1 AS SELECT 1 AS a | {} | {integer} (1 row) -- should fail @@ -33,18 +43,18 @@ EXECUTE q1; PREPARE q2 AS SELECT 2 AS b; SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements; - name | statement | parameter_types | result_types -------+------------------------------+-----------------+-------------- - q1 | PREPARE q1 AS SELECT 2; | {} | {integer} - q2 | PREPARE q2 AS SELECT 2 AS b; | {} | {integer} + name | statement | parameter_types | result_types +------+-----------------------------+-----------------+-------------- + q1 | PREPARE q1 AS SELECT 2 | {} | {integer} + q2 | PREPARE q2 AS SELECT 2 AS b | {} | {integer} (2 rows) -- sql92 syntax DEALLOCATE PREPARE q1; SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements; - name | statement | parameter_types | result_types -------+------------------------------+-----------------+-------------- - q2 | PREPARE q2 AS SELECT 2 AS b; | {} | {integer} + name | statement | parameter_types | result_types +------+-----------------------------+-----------------+-------------- + q2 | PREPARE q2 AS SELECT 2 AS b | {} | {integer} (1 row) DEALLOCATE PREPARE q2; @@ -168,20 +178,20 @@ SELECT name, statement, parameter_types, result_types FROM pg_prepared_statement ------+------------------------------------------------------------------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------- q2 | PREPARE q2(text) AS +| {text} | {name,boolean,boolean} | SELECT datname, datistemplate, datallowconn +| | - | FROM pg_database WHERE datname = $1; | | + | FROM pg_database WHERE datname = $1 | | q3 | PREPARE q3(text, int, float, boolean, smallint) AS +| {text,integer,"double precision",boolean,smallint} | {integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,name,name,name} | SELECT * FROM tenk1 WHERE string4 = $1 AND (four = $2 OR+| | | ten = $3::bigint OR true = $4 OR odd = $5::int) +| | - | ORDER BY unique1; | | + | ORDER BY unique1 | | q5 | PREPARE q5(int, text) AS +| {integer,text} | {integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,name,name,name} | SELECT * FROM tenk1 WHERE unique1 = $1 OR stringu1 = $2 +| | - | ORDER BY unique1; | | + | ORDER BY unique1 | | q6 | PREPARE q6 AS +| {integer,name} | {integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,integer,name,name,name} - | SELECT * FROM tenk1 WHERE unique1 = $1 AND stringu1 = $2; | | + | SELECT * FROM tenk1 WHERE unique1 = $1 AND stringu1 = $2 | | q7 | PREPARE q7(unknown) AS +| {path} | {text,path} - | SELECT * FROM road WHERE thepath = $1; | | + | SELECT * FROM road WHERE thepath = $1 | | q8 | PREPARE q8 AS +| {integer,name} | - | UPDATE tenk1 SET stringu1 = $2 WHERE unique1 = $1; | | + | UPDATE tenk1 SET stringu1 = $2 WHERE unique1 = $1 | | (6 rows) -- test DEALLOCATE ALL; diff --git a/src/test/regress/sql/prepare.sql b/src/test/regress/sql/prepare.sql index c6098dc95ce..0e7fe44725e 100644 --- a/src/test/regress/sql/prepare.sql +++ b/src/test/regress/sql/prepare.sql @@ -4,7 +4,7 @@ SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements; -PREPARE q1 AS SELECT 1 AS a; +SELECT 'bingo'\; PREPARE q1 AS SELECT 1 AS a \; SELECT 42; EXECUTE q1; SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements; -- 2.52.0 --biRhQYMBrGQlqcCN-- ^ permalink raw reply [nested|flat] 394+ messages in thread
end of thread, other threads:[~2025-12-24 14:31 UTC | newest] Thread overview: 394+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v11 3/9] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH 4/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v10 3/3] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v12 3/5] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2020-10-31 04:52 [PATCH v13 04/18] ReindexPartitions() to set indisvalid.. Justin Pryzby <[email protected]> 2025-12-24 14:31 [PATCH v1] Cleanup explicit PREPARE query strings Julien Rouhaud <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox