This is an automated email from the ASF dual-hosted git repository. leborchuk pushed a commit to branch REL_2_STABLE in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit aaf5f9180a31378bc12dac7252159e4a943452a0 Author: Michael Paquier <[email protected]> AuthorDate: Thu Jan 18 16:31:50 2024 +0900 Improve handling of dropped partitioned indexes for REINDEX INDEX A REINDEX INDEX done on a partitioned index builds a list of the indexes to work on before processing its partitions in individual transactions. When combined with a DROP of the partitioned index, there was a window where it was possible to see some unexpected "could not open relation with OID", synonym of relation lookup error. The code was robust enough to handle the case where the parent relation is missing, but not the case where an index would be gone missing. This is similar to 1d65416661bb. Support for REINDEX on partitioned relations has been introduced in a6642b3ae060, so backpatch down to 14. Author: Fei Changhong Discussion: https://postgr.es/m/[email protected] Backpatch-through: 14 (cherry picked from commit b6f2e019d66ffaa3435d51a554ceacbee868a0e4) --- src/backend/catalog/index.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 7035c4a74b2..c1c003b21d4 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -3806,7 +3806,24 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, * Open the target index relation and get an exclusive lock on it, to * ensure that no one else is touching this particular index. */ - iRel = index_open(indexId, AccessExclusiveLock); + if ((params->options & REINDEXOPT_MISSING_OK) != 0) + iRel = try_index_open(indexId, AccessExclusiveLock); + else + iRel = index_open(indexId, AccessExclusiveLock); + + /* if index relation is gone, leave */ + if (!iRel) + { + /* Roll back any GUC changes */ + AtEOXact_GUC(false, save_nestlevel); + + /* Restore userid and security context */ + SetUserIdAndSecContext(save_userid, save_sec_context); + + /* Close parent heap relation, but keep locks */ + table_close(heapRelation, NoLock); + return; + } if (progress) pgstat_progress_update_param(PROGRESS_CREATEIDX_ACCESS_METHOD_OID, --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
