Duplicate entries in pg_depend after REINDEX CONCURRENTLY
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Date: 2019-10-25T06:43:18Z
Lists: pgsql-hackers
Attachments
- reindex-conc-deps.patch (text/x-diff) patch
Hi all, While digging into a separate issue, I have found a new bug with REINDEX CONCURRENTLY. Once the new index is built and validated, a couple of things are done at the swap phase, like switching constraints, comments, and dependencies. The current code moves all the dependency entries of pg_depend from the old index to the new index, but it never counted on the fact that the new index may have some entries already. So, once the swapping is done, pg_depend finishes with duplicated entries: the ones coming from the old index and the ones of the index freshly-created. For example, take an index which uses an attribute or an expression and has dependencies with the parent's columns. Attached is a patch to fix the issue. As we know that the old index will have a definition and dependencies that match with the old one, I think that we should just remove any dependency records on the new index before moving the new set of dependencies from the old to the new index. The patch includes regression tests that scan pg_depend to check that everything remains consistent after REINDEX CONCURRENTLY. Any thoughts? -- Michael
Commits
-
Fix dependency handling at swap phase of REINDEX CONCURRENTLY
- 5e5f32284d69 12.1 landed
- 68ac9cf24992 13.0 landed