Skip to content

[Bug]: ALTER PUBLICATION ... DATABASE <db> without TABLE clause cannot reset table scope back to all tables ('*') — narrowed scope is permanent until drop+recreate #30611

Open

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

b24d1b3

Other Environment Information

  • Hardware: macOS arm64 (Apple Silicon)
  • Topology: single-node standalone
  • OS: macOS

Actual Behavior

ALTER PUBLICATION <pub> DATABASE <db> (without a TABLE clause) cannot reset a table-scoped publication back to all tables. The ALTER executes (update_time changes) but the tables field silently keeps its old value, and subscribers never see the newly excluded tables come back.

Sequence:

create database tblpub;
create table tblpub.keep (id int primary key);
create table tblpub.dropme (id int primary key);
insert into tblpub.keep values (1); insert into tblpub.dropme values (9);
create publication pubT database tblpub account acc1;             -- tables = '*' (all)

-- subscriber (acc1):
create database subT from sys publication pubT;                    -- sees keep + dropme ✓

-- publisher:
alter publication pubT database tblpub table keep;                 -- narrows to 'keep' ✓ (subscriber loses dropme ✓)
alter publication pubT database tblpub;                            -- intent: broaden back to ALL tables

show publications;   -- tables column STILL 'keep' (never returns to '*')
-- on subscriber, 12s and counting: dropme never comes back

Observed: show publications after the second ALTER: pubT | tblpub | keep | ... — update_time advanced but the table scope never reverts to *. The subscriber remains narrowed, and data in dropme is permanently invisible to it.

Root cause

doAlterPublication (pkg/frontend/publication_subscription.go:569):

tablesStr := pub.TablesStr        // defaults to the OLD value
if len(ap.Table) > 0 {            // only an explicit TABLE clause updates it
    tablesStr = genPubTablesStr(...)
}

There is no branch for "no TABLE clause ⇒ reset to all tables (*)". CREATE defaults to all-tables (tablesStr := pubsub.TableAll, line 320), so the semantics are asymmetric: a table-scoped publication can be narrowed but never re-broadened via ALTER — the user has to drop and recreate the publication (breaking all live subscriptions), while the natural ALTER ... DATABASE x form silently does nothing except touch update_time.

The same len(ap.Table) > 0 condition at line 464 also skips invalidatePublicationViewMetadata for this case, so even the stale-scope metadata invalidation is skipped.

Expected Behavior

ALTER PUBLICATION <pub> DATABASE <db> without a TABLE clause should reset the published table scope to all tables (*), mirroring the CREATE-time default — or reject the statement as incomplete. Silently keeping the old scope leaves the user no path back without drop+recreate (which destroys subscriptions).

Steps to Reproduce

  1. Create pub/sub pair with a two-table database (as above)
  2. alter publication pubT database tblpub table keep; — narrowing works, subscriber reflects it
  3. alter publication pubT database tblpub; — re-broaden attempt
  4. show publications; — tables column still keep; subscriber's dropme never returns

Additional information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions