Skip to content

pg_repack is aborted with error if a publication FOR ALL TABLES exist#481

Open
Melkij wants to merge 2 commits intoreorg:masterfrom
Melkij:error_with_publication_for_all_tables
Open

pg_repack is aborted with error if a publication FOR ALL TABLES exist#481
Melkij wants to merge 2 commits intoreorg:masterfrom
Melkij:error_with_publication_for_all_tables

Conversation

@Melkij
Copy link
Collaborator

@Melkij Melkij commented Mar 17, 2026

pg_repack is aborted with error if a publication FOR ALL TABLES exists and apply_log requires deleting or updating a row in a temporary table.

Reproduction:

create table foo(id int primary key, val text);
insert into foo values (1, 'hi!');
create publication foo for all tables ;
# start pg_repack with break at rebuild_indexes
update foo set val = 'h2' where id = 1;
# continue pg_repack process and see error like this:

ERROR: query failed: ERROR:  cannot update table "table_16388" because it does not have a replica identity and publishes updates
HINT:  To enable updating the table, set REPLICA IDENTITY using ALTER TABLE.
CONTEXT:  SQL statement "UPDATE repack.table_16388 SET (id, val) = ($2.id, $2.val) WHERE (id) = ($1.id)"
DETAIL: query was: SELECT repack.repack_apply($1, $2, $3, $4, $5, $6)

It's not that difficult to format ALTER TABLE repack.table_' || R.oid || ' REPLICA IDENTITY USING INDEX index_' || PK.indexrelid in repack.tables, but for this to work, I also need to set NOT NULL on columns, which is less trivial. Furthermore, repack might break subscribers of this publication.

Given the lack of previous bug reports (this setup never worked since introduction of publications in pg10), I suggest adding a check for publications FOR ALL TABLES and simply refusing to work in such a database by default.

Melkij added 2 commits March 17, 2026 13:51
…s and apply_log requires deleting or updating a row in a temporary table.

ERROR:  cannot update table "table_16388" because it does not have a replica identity and publishes updates

It's not that difficult to format `ALTER TABLE repack.table_' || R.oid || ' REPLICA IDENTITY USING INDEX index_' || PK.indexrelid` in repack.tables, but for this to work, I also need to set NOT NULL on columns, which is less trivial. Furthermore, repack might break subscribers of this publication.

Given the lack of previous bug reports (this setup never worked since introduction of publications in pg10), I suggest adding a FOR ALL TABLES check for publications and simply refusing to work in such a database by default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant