Repository navigation
Conversation
…tables before stopping its replication The tables of a `MaterializedPostgreSQL` database can be detached only permanently: `DatabaseMaterializedPostgreSQL::detachTable` throws `NOT_IMPLEMENTED`. `DETACH DATABASE` failed at its first table, but only after `executeToDatabaseImpl` had stopped the replication and prepared all tables for shutdown, so the database stayed attached and no longer replicated until a restart. Refuse it before anything is stopped. Related: ClickHouse#127875 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
Closing in favour of #127896, which was opened earlier and fixes all of #127875: it refuses |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #127875
Related: #123694
The tables of a
MaterializedPostgreSQLdatabase can be detached only permanently:DatabaseMaterializedPostgreSQL::detachTablealways throwsNOT_IMPLEMENTED("DETACH TABLE not allowed, use DETACH PERMANENTLY"). SoDETACH DATABASEof such a database with tables could never succeed, but it failed only at its first table, afterInterpreterDropQuery::executeToDatabaseImplhad already calledstopReplicationand prepared all tables for shutdown (flushAndPrepareForShutdown; the first table also gotflushAndShutdown). The database stayed attached, but changes in PostgreSQL were no longer replicated until a server restart, and nothing in the error said so.Now
executeToDatabaseImplrefusesDETACH DATABASEof a non-emptyMaterializedPostgreSQLdatabase right after waiting for the database to start, before stopping the replication or touching any table. The error code staysNOT_IMPLEMENTED; the message names the alternatives (DROP DATABASE, orDETACH TABLE ... PERMANENTLYfor each table). Detaching an empty database is unchanged.test_postgresql_replica_database_engine/test_2.py::test_detach_database_keeps_replicationchecks thatDETACH DATABASEis refused and that rows inserted in PostgreSQL afterwards are still replicated. It fails on the official master build and passes with the fix (3 of 3 runs), as do the other tests intest_2.py.Not covered: a
DROP DATABASEthat is refused by its checks (for example bymax_table_size_to_drop) also runs afterstopReplication, and leaves aReplicatedorMaterializedPostgreSQLdatabase without replication. That part of #127875 is left to #123694, which moves these checks; the issue stays open for it. Also not covered: aDETACH DATABASEwhile the initial snapshot of a new database is still running. Its nested tables do not exist yet, so the check lets it through,stopReplicationwaits for the snapshot to finish, and the detach fails at the first table as before.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
DETACH DATABASEof aMaterializedPostgreSQLdatabase with tables, which is not supported, no longer stops the replication of the database before failing.🤖 Generated with Claude Code