Skip to content

Fix NOT_IMPLEMENTED exception in system.detached_tables for DatabaseDictionary and similar engines - #107943

Merged
tuanpach merged 32 commits into
ClickHouse:masterfrom
adityaksolves:fix/system-detached-tables-not-implemented
Aug 26, 2026
Merged

tuanpach merged 32 commits into
ClickHouse:masterfrom
adityaksolves:fix/system-detached-tables-not-implemented

Conversation

@adityaksolves

@adityaksolves adityaksolves commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #104868

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry:

Fixed SELECT * FROM system.detached_tables throwing NOT_IMPLEMENTED exception when databases like DatabaseDictionary, DatabaseOverlay, DatabaseFilesystem, or DatabaseS3 exist. Such databases are now silently skipped during iteration.

Problem

SELECT * FROM system.detached_tables fails with Cannot get detached tables for DatabaseDictionary. (NOT_IMPLEMENTED) when any Dictionary or similar database exists on the server.

Root cause: getDetachedTablesIterator was called without error handling in both StorageSystemDetachedTables.cpp and StorageSystemTables.cpp. Databases like DatabaseDictionary, DatabaseOverlay, DatabaseFilesystem, DatabaseHDFS, and DatabaseS3 do not override this method and throw NOT_IMPLEMENTED.

Fix

Wrapped getDetachedTablesIterator calls in try-catch blocks in both affected files. Databases that throw NOT_IMPLEMENTED are now silently skipped, allowing the query to return results from supported databases.

Test

Added stateless test 04357_system_detached_tables_not_implemented covering:

  • DatabaseDictionary coexisting with a normal Atomic database
  • Detached table correctly visible from normal database
  • No exception thrown when unsupported database engines exist

Workflow [PR]
Sync PR [sync-upstream/pr/107943]

@zlareb1 zlareb1 added the can be tested Allows running workflows for external contributors label Jul 7, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c769898]

Summary: ✅


AI Review

Summary

This PR no longer only skips unsupported databases in system.detached_tables: on the current head it also implements detached-table reporting for DatabaseOverlay, DatabaseMySQL, and DatabasePostgreSQL, plus reconciliation/documentation/tests around permanent-detach markers. The remaining concern is evidence rather than the core code path: the PostgreSQL permanent-marker regression test still does not prove DatabasePostgreSQL::removeOutdatedTables, and the changelog entry no longer matches the behavior at the PR head.

PR Metadata
  • Changelog category: Bug Fix still fits the actual change.
  • Changelog entry: required, but the current text is stale. DatabaseOverlay is no longer "silently skipped"; it now reports detached tables, and the PR also adds DatabaseMySQL / DatabasePostgreSQL detached-table support and reconciliation behavior.
  • Exact replacement: Fixed system.detached_tables for databases whose detached-table iterator was unsupported or incomplete: engines without detached-table support are now skipped instead of throwing NOT_IMPLEMENTED, and DatabaseOverlay, DatabaseMySQL, and DatabasePostgreSQL now report detached tables correctly.
Tests
  • ⚠️ [tests/integration/test_postgresql_database_engine/test.py:686-709] SHOW TABLES only refreshes the live PostgreSQL table list; it does not call DatabasePostgreSQL::removeOutdatedTables. The loop then accepts the same count == 1 && is_permanently == 1 state that was already asserted before the cleaner had a chance to run, so test_postgresql_permanent_detach_marker_preserved_after_remote_drop can still pass without exercising the reconciliation branch this PR changed. Make the post-cleaner state observably different from the pre-cleaner state, or trigger/wait for the cleaner directly.
Final Verdict

Changes requested: the detached-table behavior itself looks consistent on the current head, but the PostgreSQL permanent-marker regression test still does not prove the new cleaner behavior, and the changelog entry should be updated to match what the PR actually does.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 87.20% 87.20% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 79.30% 79.40% +0.10%

Changed lines: Changed C/C++ lines covered: 118/168 (70.24%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 7, 2026
@adityaksolves
adityaksolves force-pushed the fix/system-detached-tables-not-implemented branch from d7efc52 to 0121d9a Compare July 9, 2026 16:33
…PostgreSQL databases

Implement getDetachedTablesIterator for DatabaseMySQL and DatabasePostgreSQL
instead of relying on the default NOT_IMPLEMENTED base implementation, so
that detached tables in these engines are correctly reported instead of
being silently skipped.
@adityaksolves

Copy link
Copy Markdown
Contributor Author

Implemented getDetachedTablesIterator for both DatabaseMySQL and DatabasePostgreSQL in the latest commit (564b599). Both now iterate over their existing detached-tables tracking sets (remove_or_detach_tables for MySQL, detached_or_dropped for PostgreSQL) and return them via SnapshotDetachedTables, so detached tables from these engines are correctly reported in system.detached_tables instead of being silently skipped.

Comment thread src/Databases/MySQL/DatabaseMySQL.cpp Resolved
…nt PostgreSQL detachTablePermanently

- DatabaseMySQL/DatabasePostgreSQL::getDetachedTablesIterator now correctly
  sets is_permanently by checking the remove-flag file on disk
- Implement DatabasePostgreSQL::detachTablePermanently, which was missing
  and caused DETACH TABLE ... PERMANENTLY to throw NOT_IMPLEMENTED
- Add integration test coverage for both engines verifying is_permanently
  is correctly reported in system.detached_tables
Comment thread src/Databases/DatabaseOverlay.cpp Resolved
system.tables does not expose a public is_detached column - it is only
an internal parameter to detail::getFilteredTables(), not a registered
column in the table's schema. The added assertions querying
'SELECT is_detached FROM system.tables' would always fail against a
real server.

Removed these invalid assertions from both MySQL and PostgreSQL
integration tests, keeping the fix scoped to system.detached_tables
where is_permanently is correctly populated and verified.
The test used hardcoded database names (test_dict_db_04357,
test_ordinary_db_04357), which caused DATABASE_ALREADY_EXISTS race
conditions when the 'flaky check' CI job ran the test multiple times
concurrently.

Replaced hardcoded names with {CLICKHOUSE_DATABASE:Identifier} and
{CLICKHOUSE_DATABASE_1:Identifier} placeholders, which the test
runner substitutes with unique per-run database names, avoiding
collisions between parallel/concurrent test runs.

Updated the .reference file to use a literal 'ordinary_db' marker
instead of the now-dynamic database name, keeping expected output
deterministic.
…names

Adds a regression test proving that DatabaseOverlay::getDetachedTablesIterator
correctly reports the overlay's own database name rather than a member
database's name when they differ. This scenario cannot be reproduced via
SQL/clickhouse-local since overlay and its members always share the same
name there, so a C++ unit test is required for proper coverage.
@adityaksolves

Copy link
Copy Markdown
Contributor Author

The CH Inc sync check is failing but doesn't appear related to this PR's changes (no file overlap, and the branch is a normal distance behind master for an active repo). Could someone confirm if this is an infra-side issue, or is there something I need to do on my end?

@adityaksolves

Copy link
Copy Markdown
Contributor Author

@zlareb1 could you take a look at the CH Inc sync failure above when you get a chance?

@adityaksolves

Copy link
Copy Markdown
Contributor Author

Hi @tuanpach — following up on the failing checks:

  1. Integration test (test_replicated_table_structure_alter): Confirmed flaky —
    CI auto-matched it to issue Flaky test: test_replicated_database/test.py::test_replicated_table_structure_alter (regression since 2026-07-10) #110036, and the retry passed cleanly. Unrelated
    to this PR.

  2. AST fuzzer (Logical error: '!part.empty()'): The crashing query happens to
    target system.detached_tables, but the actual crash is in WindowNode/
    IdentifierNode::toASTImpl (AST reconstruction for a WINDOW ... PARTITION BY
    clause) — unrelated to this PR's getDetachedTablesIterator changes. Looks
    like a pre-existing parser edge case triggered by a fuzzer-generated
    malformed identifier in the window clause, independent of which table is
    queried.

  3. Stress test (Received signal 8): Stack trace shows generic std::chrono code,
    no overlap with files this PR touches.

Could you trigger a re-run for these jobs? Happy to dig deeper into any of
these if you'd like.

@tuanpach

Copy link
Copy Markdown
Member

@groeneai Check the CI failure

@adityaksolves, I have a concern related to DatabaseMySQL and DatabasePostgreSQL. dropTable actually detaches that table. When listing detached tables for these DBs, it actually lists the dropped tables.

@tuanpach tuanpach self-assigned this Jul 20, 2026
Comment thread src/Databases/MySQL/DatabaseMySQL.cpp Resolved
alexey-milovidov pushed a commit to SteveBalayanAKAMedian/ClickHouse that referenced this pull request Aug 19, 2026
skip_degree is the first byte of a serialized AggregateFunction(uniq, ...)
state and read() accepted any value for it. Three sites shift by it:
size() shifts a UInt64 twice, and good() shifts a UInt32, so a degree of
32 or more is undefined behaviour. UBSan reported the 64-bit shift from
the AST fuzzer; on x86 the exponent is taken modulo 64, so a state
declaring degree 128 silently returned the cardinality of degree 0
instead.

Thinning leaves at most 2 ^ (32 - skip_degree) hashes and shrinkIfNeed()
raises the degree only while more than UNIQUES_HASH_MAX_SIZE of them
remain, so the last degree it can produce is one past the thinning
budget. Both writers of the field are now bounded by that maximum.
read() rejects a larger value off the wire with INCORRECT_DATA.
shrinkIfNeed() throws rather than incrementing past it, which is needed
because reinsertImpl() does not dedupe: a deserialized buffer repeating
one maximally divisible hash keeps a count that thinning cannot reduce,
so the loop would otherwise raise the degree without limit and reach the
undefined shift in good(). ReservoirSamplerDeterministic bounds both of
its writers the same way, by rejection in read() and by a throw in
setSkipDegree().

The last accepted degree still admits a count that saturates the hash
space: at degree 16 with 65536 hashes the thinned count reaches 2 ^ 32,
so the systematic-error correction subtracts it from 2 ^ 32, underflows
the difference, and casts a negative double to size_t. Since write()
serializes that state, rejecting it on read would refuse input
ClickHouse itself produced, so size() saturates the count instead and
reports the largest value the correction can express.

Every state a released version could write is still accepted:
UNIQUES_HASH_MAX_SIZE_DEGREE has been 17 for the file's whole history,
so no writer could emit a larger degree, and size() is now defined for
every state that passes the check. No format change and no new setting.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107943&sha=1a89f6f2660c232730fd45bc1878d5d8443f7350&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan_ubsan%29
ClickHouse#107943
adityaksolves added a commit to adityaksolves/Clickhouse that referenced this pull request Aug 20, 2026
…iation

The DatabasePostgreSQL::removeOutdatedTables background task was unconditionally
removing both detached_or_dropped entries and .removed marker files whenever a
table disappeared from the remote PostgreSQL server. This broke the permanent
detach semantics: after DROP TABLE or DETACH TABLE PERMANENTLY, if the upstream
table was dropped and later recreated with the same name, it would incorrectly
reappear in ClickHouse instead of staying hidden until explicit ATTACH TABLE.

This fix applies the same logic as the DatabaseMySQL permanent marker preservation
(commit 1986888), which correctly distinguishes:
- Ordinary DETACH TABLE: entry is pruned when remote table disappears
- Permanent detach (DROP TABLE / DETACH PERMANENTLY): .removed marker and entry
  are preserved even if remote table is recreated

The reconciliation loop now checks db_disk->existsFile(marker_path) before
erasing entries, preserving permanent detach state as documented in
docs/reference/system-tables/detached_tables.mdx.

Added comprehensive integration tests covering:
1. is_permanently field correctness for both DETACH types
2. Permanent marker preservation after remote DROP + recreation
3. Ordinary detach entry pruning after remote DROP

Addresses AI review comment on docs/reference/system-tables/detached_tables.mdx
regarding PostgreSQL permanent detach contract preservation.

PR: ClickHouse#107943
drop_postgres_table(cursor, "test_prune")

# Trigger schema refresh
node1.query("SHOW TABLES FROM postgres_prune_test")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHOW TABLES does not drive the code you are trying to validate here. DatabasePostgreSQL::getTablesIterator only fetches the remote table list and filters detached_or_dropped; the pruning logic lives exclusively in DatabasePostgreSQL::removeOutdatedTables, which is scheduled once in loadStoredObjects and then rescheduled after cleaner_reschedule_ms = 60000.

That means the time.sleep(2) below is just racing the background task: test_postgresql_ordinary_detach_pruned_after_remote_drop can still see pruned_count = 1, and the permanent-marker test above can pass without ever exercising the new reconciliation branch. Please make this deterministic (for example by exposing a direct trigger or using a controllable reschedule interval in the test) before relying on it as regression coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cedf6d3 — replaced the fixed time.sleep(2) with a poll-based wait
in both tests, so they now genuinely wait for removeOutdatedTables() to
complete instead of racing it.

Changes:

  • Both tests now poll every 5 seconds (up to 65s max) checking the actual
    post-reconciliation state (detached_tables count and is_permanently for
    the marker test, entry-pruned for the ordinary-detach test) instead of
    sleeping a fixed 2 seconds and hoping the background task already ran.
  • Tests break early once the condition is met, so they don't add unnecessary
    wait time in the common case.
  • cleaner_reschedule_ms is left unchanged at 60000 in production code —
    no behavior change outside the test.
  • If the condition still isn't met within the timeout, the assertion
    failure message reports the actual observed state, making failures
    easier to diagnose.

This should now deterministically exercise the removeOutdatedTables()
reconciliation path in both directions (permanent marker preserved /
non-permanent entry pruned) rather than depending on test timing luck.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still short-circuits before removeOutdatedTables has to run. At tests/integration/test_postgresql_database_engine/test.py:671-681 the test already establishes the pre-cleaner state (count == 1, is_permanently == 1) immediately after DROP TABLE, and the new loop at :696-709 exits on that same condition. SHOW TABLES at :687 only refreshes the live table list; it does not call removeOutdatedTables.

So the test can still pass without ever exercising the reconciliation branch that this PR changed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/integration/test_postgresql_database_engine/test.py:670-709 still proves only the pre-cleaner state. The test asserts count == 1 and is_permanently == 1 immediately after DROP TABLE at :670-681, and the polling loop at :696-709 exits on that same condition. SHOW TABLES at :687 only refreshes the live table list; it does not call DatabasePostgreSQL::removeOutdatedTables, so this can still pass without the scheduled cleaner ever running.

adityaksolves added a commit to adityaksolves/Clickhouse that referenced this pull request Aug 20, 2026
…liation

The tests for permanent detach marker preservation were using time.sleep(2),
but the background cleaner_task (removeOutdatedTables) runs every 60 seconds.
This meant the tests never actually exercised the reconciliation logic they
were supposed to verify.

Changed both tests to use a poll-based wait pattern:
- Check condition every 5 seconds
- Wait up to 65 seconds (slightly more than the 60s task interval)
- Break early if condition is met (efficient in best case)

This ensures the tests actually verify that removeOutdatedTables preserves
permanent detach markers (.removed files) and prunes ordinary detach entries
as intended.

Addresses AI review comment on test_postgresql_database_engine/test.py
in PR ClickHouse#107943
Comment thread src/Databases/MySQL/DatabaseMySQL.cpp Resolved
When a MySQL-mapped table is permanently detached (via DETACH TABLE
PERMANENTLY or DROP TABLE), a .remove_flag marker file records the
permanent detach state. However, both on-demand and background
reconciliation were unconditionally deleting this marker when the
remote MySQL table disappeared, causing a behavior regression:

- User permanently detaches table foo
- Remote table foo is dropped
- Marker is deleted by reconciliation
- Remote table foo is recreated
- Table foo automatically reappears in ClickHouse (wrong!)

This fix modifies both reconciliation code paths to check if a
.remove_flag marker exists before deleting it. Permanent detach
markers are now preserved even when the remote table disappears,
ensuring that a same-name table recreated remotely stays hidden
until explicit ATTACH TABLE — matching the documented behavior.

Changes:
- destroyLocalCacheExtraTables: gate marker deletion on !is_permanent
- cleanOutdatedTables: same gating for background reconciliation
- Updated test expecting wrong behavior
- Added comprehensive regression test

Fixes reconciliation logic to align with docs/reference/system-tables/
detached_tables.mdx documented semantics.
…iation

The DatabasePostgreSQL::removeOutdatedTables background task was unconditionally
removing both detached_or_dropped entries and .removed marker files whenever a
table disappeared from the remote PostgreSQL server. This broke the permanent
detach semantics: after DROP TABLE or DETACH TABLE PERMANENTLY, if the upstream
table was dropped and later recreated with the same name, it would incorrectly
reappear in ClickHouse instead of staying hidden until explicit ATTACH TABLE.

This fix applies the same logic as the DatabaseMySQL permanent marker preservation
(commit 1986888), which correctly distinguishes:
- Ordinary DETACH TABLE: entry is pruned when remote table disappears
- Permanent detach (DROP TABLE / DETACH PERMANENTLY): .removed marker and entry
  are preserved even if remote table is recreated

The reconciliation loop now checks db_disk->existsFile(marker_path) before
erasing entries, preserving permanent detach state as documented in
docs/reference/system-tables/detached_tables.mdx.

Added comprehensive integration tests covering:
1. is_permanently field correctness for both DETACH types
2. Permanent marker preservation after remote DROP + recreation
3. Ordinary detach entry pruning after remote DROP

Addresses review comment on docs/reference/system-tables/detached_tables.mdx
regarding PostgreSQL permanent detach contract preservation.

PR: ClickHouse#107943
Line 726 had an f-string without placeholders, flagged by ruff F541.
Changed to regular string literal.
…liation

The tests for permanent detach marker preservation were using time.sleep(2),
but the background cleaner_task (removeOutdatedTables) runs every 60 seconds.
This meant the tests never actually exercised the reconciliation logic they
were supposed to verify.

Changed both tests to use a poll-based wait pattern:
- Check condition every 5 seconds
- Wait up to 65 seconds (slightly more than the 60s task interval)
- Break early if condition is met (efficient in best case)

This ensures the tests actually verify that removeOutdatedTables preserves
permanent detach markers (.removed files) and prunes ordinary detach entries
as intended.

Addresses review comment on test_postgresql_database_engine/test.py
in PR ClickHouse#107943
…ries

The background reconciliation in DatabaseMySQL::cleanOutdatedTables was running
unconditionally whenever remove_or_detach_tables was non-empty. This caused
unnecessary remote schema fetches and error-level logging during expected MySQL
outages, even when a database legitimately sits with only permanent markers
from DROP TABLE / DETACH TABLE PERMANENTLY that can never be pruned.

Changes:
1. Gate the periodic fetchTablesWithModificationTime on the presence of at least
   one non-permanent detach entry (no .remove_flag marker exists)
2. Skip the remote fetch entirely if all entries are permanent markers
3. Use LogsLevel::warning instead of default error level for expected connection
   failures during background reconciliation

This avoids spurious error-level logs every 30 seconds when the remote is
unreachable but only permanent detach markers are present (expected scenario).

Addresses review comment on src/Databases/MySQL/DatabaseMySQL.cpp regarding
background reconciliation optimization.

PR: ClickHouse#107943
@adityaksolves
adityaksolves force-pushed the fix/system-detached-tables-not-implemented branch from cedf6d3 to 6af8a11 Compare August 20, 2026 12:11
…ination

1. Test: test_permanent_detach_marker_preserved_after_remote_drop now creates
   both a permanent and an ordinary detach entry, so has_non_permanent_detach
   evaluates true and the reconciliation block actually runs. Replaced blind
   time.sleep(35) with a polling loop (max 65s) mirroring the PostgreSQL test
   fix pattern (commit e2c7af2).

2. Logging: introduced mysqlToleratedConnectionFailureLogLevel() to
   discriminate expected connection failures (warning level) from other
   exceptions (error level) in the background reconciliation catch block,
   preventing logic bugs from being silently hidden as warnings.

Addresses review comments on PR ClickHouse#107943.
Fixes style check failure in DatabaseMySQL.cpp by adding Ok comment
to catch-all exception handler.

Fixes arm_tidy build failure by resolving ambiguous function call:
- Consolidated duplicate mysqlToleratedConnectionFailureLogLevel functions
- Enhanced original function with Poco::Net::NetException handler
- Removed duplicate from anonymous namespace
Test claimed to verify background reconciliation but SHOW TABLES
triggered destroyLocalCacheExtraTables, pruning ordinary_table
immediately and causing has_non_permanent_detach to become false,
which skipped the background fetch block entirely.

Removed SHOW TABLES call and on-demand assertions. Polling loop now
genuinely waits for background cleaner to execute its fetch path.
@adityaksolves

Copy link
Copy Markdown
Contributor Author

All review feedback has been addressed — the PostgreSQL and MySQL background reconciliation tests now genuinely exercise the cleaner path instead of racing it, and the style/build issues from the last round are fixed. CI is green and this has an approval, so this should be ready to merge whenever convenient. Thanks for the thorough review throughout — flagging the reconciliation test gaps repeatedly really helped tighten this up.

@tuanpach
tuanpach added this pull request to the merge queue Aug 26, 2026
Merged via the queue into ClickHouse:master with commit 4d9e62c Aug 26, 2026
178 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 26, 2026
@clickgapai

Copy link
Copy Markdown
Contributor
Reproducer

Shell reproducer — run against a local ClickHouse build (bash <script> <clickhouse-binary>); requires the referenced test fixtures from the repo.

# any supported release binary (25.8 .. 26.7); clickhouse-local's default database is a DatabaseOverlay
clickhouse local --query "SELECT count() FROM system.detached_tables"
# Code: 48. DB::Exception: Cannot get detached tables for DatabaseOverlay. (NOT_IMPLEMENTED)

# same on a server, with a Dictionary database present:
CREATE DATABASE dictdb ENGINE = Dictionary;
SELECT count() FROM system.detached_tables WHERE database = 'dictdb';
-- Code: 48. DB::Exception: Cannot get detached tables for DatabaseDictionary. (NOT_IMPLEMENTED)

▶ Run on ClickHouse Fiddle

Results:

  • Reproduces on: 26.7, 26.6, 26.5, 26.3, 25.8
  • Does not reproduce on: master
  • Tested versions: master, 26.7, 26.6, 26.5, 26.3, 25.8
  • Also tested (unsupported, context only): 26.2 reproduces
  • ✓ Fix is on master — this PR's change fixes the bug on master. The releases listed above still have the bug and need the backport.

Backport the fix to 26.7, 26.6, 26.5, 26.3, 25.8.

CC component owner: @alexey-milovidov @kssenii

Analysis metadata

comp-system-table · Severity P2 · Finding phase_d_pr107943

  • Verified against master build 573230bfe668 (aarch64)
Introducing change: not identified
  • No clean release baseline found and no lower bound established — source-build bisect is required to pin the introducing PR (not yet performed).
  • Walked 6 release(s) below the supported window: still reproduces down to 25.2.
  • Secondary components: comp-foreign-db, comp-database-engines

@clickgapai

Copy link
Copy Markdown
Contributor

@adityaksolves @tuanpach — title/description suggestions:

Description (currently incomplete):

  • Why: The body describes only the try/catch fix. It does not mention the new DatabaseOverlay/DatabaseMySQL/DatabasePostgreSQL getDetachedTablesIterator implementations, the new DatabasePostgreSQL::detachTablePermanently, the rewritten detach reconciliation in DatabaseMySQL::destroyLocalCacheExtraTables and DatabasePostgreSQL::removeOutdatedTables, or the new remote-schema poll inside the DatabaseMySQL cleaner thread. Roughly 80% of the diff is undescribed.

  • Suggested addition:

    Also in this PR (beyond the NOT_IMPLEMENTED fix)

    • DatabaseOverlay::getDetachedTablesIterator — new; merges member databases, reports the overlay's own database name.
    • DatabaseMySQL::getDetachedTablesIterator / DatabasePostgreSQL::getDetachedTablesIterator — new; is_permanently derived from the .remove_flag / .removed marker file.
    • DatabasePostgreSQL::detachTablePermanently — new; DETACH TABLE ... PERMANENTLY previously threw NOT_IMPLEMENTED for this engine.
    • Reconciliation semantics change: a permanent detach marker is now preserved when the remote table disappears, so a remotely-recreated same-name table stays hidden until an explicit ATTACH TABLE. Previously the entry and marker were pruned and the table reappeared.
    • DatabaseMySQL::cleanOutdatedTables now fetches the remote schema every 30s when a non-permanently-detached table exists, releasing the database mutex for the duration of the network call.

Ignore if intentional.

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

Labels

can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

system.detached_tables throws NOT_IMPLEMENTED when iterating over DatabaseDictionary

6 participants