pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va 6+ messages / 1 participants [nested] [flat]
* pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va @ 2023-01-21 18:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-01-21 18:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow REPLICA IDENTITY to be set on an index that's not (yet) valid. The motivation for this change is that when pg_dump dumps a partitioned index that's marked REPLICA IDENTITY, it generates a command sequence that applies REPLICA IDENTITY before the partitioned index has been marked valid, causing restore to fail. We could perhaps change pg_dump to not do it like that, but that would be difficult and would not fix existing dump files with the problem. There seems to be very little reason for the backend to disallow this anyway --- the code ignores indisreplident when the index isn't valid --- so instead let's fix it by allowing the case. Commit 9511fb37a previously expressed a concern that allowing indisreplident to be set on invalid indexes might allow us to wind up in a situation where a table could have indisreplident set on multiple indexes. I'm not sure I follow that concern exactly, but in any case the only way that could happen is because relation_mark_replica_identity is too trusting about the existing set of markings being valid. Let's just rip out its early-exit code path (which sure looks like premature optimization anyway; what are we doing expending code to make redundant ALTER TABLE ... REPLICA IDENTITY commands marginally faster and not-redundant ones marginally slower?) and fix it to positively guarantee that no more than one index is marked indisreplident. The pg_dump failure can be demonstrated in all supported branches, so back-patch all the way. I chose to back-patch 9511fb37a as well, just to keep indisreplident handling the same in all branches. Per bug #17756 from Sergey Belyashov. Discussion: https://postgr.es/m/17756-dd50e8e0c8dd4a40@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/c9f7f926484d69e2806e35343af7e472fadfede7 Modified Files -------------- src/backend/catalog/index.c | 5 +- src/backend/commands/tablecmds.c | 64 +++++++++----------------- src/test/regress/expected/replica_identity.out | 37 +++++++++++++++ src/test/regress/sql/replica_identity.sql | 20 ++++++++ 4 files changed, 81 insertions(+), 45 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va @ 2023-01-21 18:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-01-21 18:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow REPLICA IDENTITY to be set on an index that's not (yet) valid. The motivation for this change is that when pg_dump dumps a partitioned index that's marked REPLICA IDENTITY, it generates a command sequence that applies REPLICA IDENTITY before the partitioned index has been marked valid, causing restore to fail. We could perhaps change pg_dump to not do it like that, but that would be difficult and would not fix existing dump files with the problem. There seems to be very little reason for the backend to disallow this anyway --- the code ignores indisreplident when the index isn't valid --- so instead let's fix it by allowing the case. Commit 9511fb37a previously expressed a concern that allowing indisreplident to be set on invalid indexes might allow us to wind up in a situation where a table could have indisreplident set on multiple indexes. I'm not sure I follow that concern exactly, but in any case the only way that could happen is because relation_mark_replica_identity is too trusting about the existing set of markings being valid. Let's just rip out its early-exit code path (which sure looks like premature optimization anyway; what are we doing expending code to make redundant ALTER TABLE ... REPLICA IDENTITY commands marginally faster and not-redundant ones marginally slower?) and fix it to positively guarantee that no more than one index is marked indisreplident. The pg_dump failure can be demonstrated in all supported branches, so back-patch all the way. I chose to back-patch 9511fb37a as well, just to keep indisreplident handling the same in all branches. Per bug #17756 from Sergey Belyashov. Discussion: https://postgr.es/m/17756-dd50e8e0c8dd4a40@postgresql.org Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9e4288ce6d30024de1586fefa6db077c5f9122c2 Modified Files -------------- src/backend/catalog/index.c | 5 +- src/backend/commands/tablecmds.c | 64 +++++++++----------------- src/test/regress/expected/replica_identity.out | 37 +++++++++++++++ src/test/regress/sql/replica_identity.sql | 20 ++++++++ 4 files changed, 81 insertions(+), 45 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va @ 2023-01-21 18:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-01-21 18:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow REPLICA IDENTITY to be set on an index that's not (yet) valid. The motivation for this change is that when pg_dump dumps a partitioned index that's marked REPLICA IDENTITY, it generates a command sequence that applies REPLICA IDENTITY before the partitioned index has been marked valid, causing restore to fail. We could perhaps change pg_dump to not do it like that, but that would be difficult and would not fix existing dump files with the problem. There seems to be very little reason for the backend to disallow this anyway --- the code ignores indisreplident when the index isn't valid --- so instead let's fix it by allowing the case. Commit 9511fb37a previously expressed a concern that allowing indisreplident to be set on invalid indexes might allow us to wind up in a situation where a table could have indisreplident set on multiple indexes. I'm not sure I follow that concern exactly, but in any case the only way that could happen is because relation_mark_replica_identity is too trusting about the existing set of markings being valid. Let's just rip out its early-exit code path (which sure looks like premature optimization anyway; what are we doing expending code to make redundant ALTER TABLE ... REPLICA IDENTITY commands marginally faster and not-redundant ones marginally slower?) and fix it to positively guarantee that no more than one index is marked indisreplident. The pg_dump failure can be demonstrated in all supported branches, so back-patch all the way. I chose to back-patch 9511fb37a as well, just to keep indisreplident handling the same in all branches. Per bug #17756 from Sergey Belyashov. Discussion: https://postgr.es/m/17756-dd50e8e0c8dd4a40@postgresql.org Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/70ec756b01a4c9e62c189a8d853401393d18cb4b Modified Files -------------- src/backend/catalog/index.c | 5 +- src/backend/commands/tablecmds.c | 64 +++++++++----------------- src/test/regress/expected/replica_identity.out | 37 +++++++++++++++ src/test/regress/sql/replica_identity.sql | 20 ++++++++ 4 files changed, 81 insertions(+), 45 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va @ 2023-01-21 18:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-01-21 18:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow REPLICA IDENTITY to be set on an index that's not (yet) valid. The motivation for this change is that when pg_dump dumps a partitioned index that's marked REPLICA IDENTITY, it generates a command sequence that applies REPLICA IDENTITY before the partitioned index has been marked valid, causing restore to fail. We could perhaps change pg_dump to not do it like that, but that would be difficult and would not fix existing dump files with the problem. There seems to be very little reason for the backend to disallow this anyway --- the code ignores indisreplident when the index isn't valid --- so instead let's fix it by allowing the case. Commit 9511fb37a previously expressed a concern that allowing indisreplident to be set on invalid indexes might allow us to wind up in a situation where a table could have indisreplident set on multiple indexes. I'm not sure I follow that concern exactly, but in any case the only way that could happen is because relation_mark_replica_identity is too trusting about the existing set of markings being valid. Let's just rip out its early-exit code path (which sure looks like premature optimization anyway; what are we doing expending code to make redundant ALTER TABLE ... REPLICA IDENTITY commands marginally faster and not-redundant ones marginally slower?) and fix it to positively guarantee that no more than one index is marked indisreplident. The pg_dump failure can be demonstrated in all supported branches, so back-patch all the way. I chose to back-patch 9511fb37a as well, just to keep indisreplident handling the same in all branches. Per bug #17756 from Sergey Belyashov. Discussion: https://postgr.es/m/17756-dd50e8e0c8dd4a40@postgresql.org Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/72d611109e65e279aa5719aba9831761f6f6c368 Modified Files -------------- src/backend/catalog/index.c | 8 +++- src/backend/commands/tablecmds.c | 64 +++++++++----------------- src/test/regress/expected/replica_identity.out | 37 +++++++++++++++ src/test/regress/sql/replica_identity.sql | 20 ++++++++ 4 files changed, 85 insertions(+), 44 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va @ 2023-01-21 18:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-01-21 18:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow REPLICA IDENTITY to be set on an index that's not (yet) valid. The motivation for this change is that when pg_dump dumps a partitioned index that's marked REPLICA IDENTITY, it generates a command sequence that applies REPLICA IDENTITY before the partitioned index has been marked valid, causing restore to fail. We could perhaps change pg_dump to not do it like that, but that would be difficult and would not fix existing dump files with the problem. There seems to be very little reason for the backend to disallow this anyway --- the code ignores indisreplident when the index isn't valid --- so instead let's fix it by allowing the case. Commit 9511fb37a previously expressed a concern that allowing indisreplident to be set on invalid indexes might allow us to wind up in a situation where a table could have indisreplident set on multiple indexes. I'm not sure I follow that concern exactly, but in any case the only way that could happen is because relation_mark_replica_identity is too trusting about the existing set of markings being valid. Let's just rip out its early-exit code path (which sure looks like premature optimization anyway; what are we doing expending code to make redundant ALTER TABLE ... REPLICA IDENTITY commands marginally faster and not-redundant ones marginally slower?) and fix it to positively guarantee that no more than one index is marked indisreplident. The pg_dump failure can be demonstrated in all supported branches, so back-patch all the way. I chose to back-patch 9511fb37a as well, just to keep indisreplident handling the same in all branches. Per bug #17756 from Sergey Belyashov. Discussion: https://postgr.es/m/17756-dd50e8e0c8dd4a40@postgresql.org Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a5f3f2fce1e90d8ca1c3ba632613fa33196e863e Modified Files -------------- src/backend/catalog/index.c | 8 +++- src/backend/commands/tablecmds.c | 64 +++++++++----------------- src/test/regress/expected/replica_identity.out | 37 +++++++++++++++ src/test/regress/sql/replica_identity.sql | 20 ++++++++ 4 files changed, 85 insertions(+), 44 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va @ 2023-01-21 18:10 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-01-21 18:10 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Allow REPLICA IDENTITY to be set on an index that's not (yet) valid. The motivation for this change is that when pg_dump dumps a partitioned index that's marked REPLICA IDENTITY, it generates a command sequence that applies REPLICA IDENTITY before the partitioned index has been marked valid, causing restore to fail. We could perhaps change pg_dump to not do it like that, but that would be difficult and would not fix existing dump files with the problem. There seems to be very little reason for the backend to disallow this anyway --- the code ignores indisreplident when the index isn't valid --- so instead let's fix it by allowing the case. Commit 9511fb37a previously expressed a concern that allowing indisreplident to be set on invalid indexes might allow us to wind up in a situation where a table could have indisreplident set on multiple indexes. I'm not sure I follow that concern exactly, but in any case the only way that could happen is because relation_mark_replica_identity is too trusting about the existing set of markings being valid. Let's just rip out its early-exit code path (which sure looks like premature optimization anyway; what are we doing expending code to make redundant ALTER TABLE ... REPLICA IDENTITY commands marginally faster and not-redundant ones marginally slower?) and fix it to positively guarantee that no more than one index is marked indisreplident. The pg_dump failure can be demonstrated in all supported branches, so back-patch all the way. I chose to back-patch 9511fb37a as well, just to keep indisreplident handling the same in all branches. Per bug #17756 from Sergey Belyashov. Discussion: https://postgr.es/m/17756-dd50e8e0c8dd4a40@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/6c122eddecc1c2e702aa05d2868a3e6a0d75bda1 Modified Files -------------- src/backend/catalog/index.c | 6 ++- src/backend/commands/tablecmds.c | 64 +++++++++----------------- src/test/regress/expected/replica_identity.out | 37 +++++++++++++++ src/test/regress/sql/replica_identity.sql | 20 ++++++++ 4 files changed, 84 insertions(+), 43 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2023-01-21 18:10 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-01-21 18:10 pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va Tom Lane <tgl@sss.pgh.pa.us> 2023-01-21 18:10 pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va Tom Lane <tgl@sss.pgh.pa.us> 2023-01-21 18:10 pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va Tom Lane <tgl@sss.pgh.pa.us> 2023-01-21 18:10 pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va Tom Lane <tgl@sss.pgh.pa.us> 2023-01-21 18:10 pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va Tom Lane <tgl@sss.pgh.pa.us> 2023-01-21 18:10 pgsql: Allow REPLICA IDENTITY to be set on an index that's not (yet) va Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox