Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
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 backObserved: 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
- Create pub/sub pair with a two-table database (as above)
alter publication pubT database tblpub table keep;— narrowing works, subscriber reflects italter publication pubT database tblpub;— re-broaden attemptshow publications;— tables column stillkeep; subscriber's dropme never returns
Additional information
- Part of the same publication/subscription hardening seam as [Bug]: RESTORE DATABASE {snapshot=...} silently deletes publications targeting the restored database and never recreates them — subscribers break permanently #30610 (snapshot restore deletes publications), [Bug]: PITR RESTORE DATABASE fails with strconv.ParseInt error when the database is referenced by a publication (published databases are unrecoverable via PITR) #30607 (PITR restore fails on published DBs), [Bug]: cross-cluster subscription always fails for non-sys tenants — 'not allowed to execute publication internal command get_databases' despite explicit ACCOUNT authorization #30603 (cross-cluster subscription denied for non-sys tenants).
- The BVT
pub_sub.sqltestsalter publication ... database ... table ...narrowing andalter ... database <newdb>(switching), but not "narrowed → ALTER without TABLE → expect all-tables reset".
Activity