Skip to content

Garbage on FS after replicated merge tree table creation with invalid zk path #33710

Closed

Description

@GrigoryPervakov

Garbage on a filesystem after error with invalid zk path, you can't create a table with fixed path due to Directory for table data data/test_db/test_table/ already exists. error.

A clear and concise description of what works not as it is supposed to.

I reproduced on 21.8.13.6 and 21.11.9.1

The list of releases

How to reproduce

  1. Create Ordinary database(issue less significant on Atomic engine, because it generates new uid on retry)
  2. Create ReplicatedMergeTree table with invalid zk path(i.e. without leading /
    CREATE TABLE test_db.test_table (id String) ENGINE = ReplicatedMergeTree('default.test_table', '{replica}') ORDER BY id SETTINGS index_granularity = 8192, get error DB::Exception: ZooKeeper path must starts with '/', got 'default.test_table'
  3. Retry query(possibly with fixed zk path), get error DB::Exception: Directory for table data data/test_db/test_table/ already exists.

Expected behavior
The failed table should not create garbage on fs.

Activity

  1. added
    potential bug
    on Jan 17, 2022
  2. added
    unexpected behaviour
    on Jan 17, 2022
  3. added
    minor
    and removed
    potential bug
    on Jan 17, 2022
  4. alexey-milovidov commented on Jan 17, 2022

    @alexey-milovidov
    Member

    This issue has very low priority because it does not happen with Atomic databases, that are by default.

  5. Alex-Burmak commented on Jan 20, 2022

    @Alex-Burmak
    Contributor

    Expected behavior
    The failed table should not create garbage on fs.

    Applicable for Atomic databases as well. It's just don't lead to errors "table already exists" on retry.

  6. den-crane commented on Jan 24, 2022

    @den-crane
    Contributor

    wa (removal of garbage folder):

    attach table test_table(s String) Engine=Log;
    drop table test_table;
    
  7. self-assigned this
    on May 12, 2022
  8. tavplubix commented on Jun 21, 2022

    @tavplubix
    Member

    Expected behavior
    The failed table should not create garbage on fs.

    Applicable for Atomic databases as well. It's just don't lead to errors "table already exists" on retry.

    For Atomic databases it's fixed in #38265. And for Ordinary databases it will not be fixed, because it's almost impossible to fix it for Ordinary engine because of its design flaws.

  9. spff commented on Sep 27, 2024

    @spff

    Hi @tavplubix , the implementation of #39872 causes performance issue when I have a lot of s3_plain disks and dropping a lot of tables (about 100x slower). Is there any possibility to only drop the stores on the disks of the database of the table instead of all the disks?

    2024.09.25 07:47:59.679453 [ 738891 ] {} <Information> DatabaseCatalog: Have 330562 tables in drop queue (0 of them are in use), will try drop XXX.YYY (7b875319-c250-44ae-b878-9c3960ff87a9)
    ...
    2024.09.25 07:47:59.688182 [ 738891 ] {} <Trace> XXX.YYY (7b875319-c250-44ae-b878-9c3960ff87a9): dropAllData: done.
    2024.09.25 07:48:00.361572 [ 738891 ] {} <Information> AWSClient: Failed to make request to: https://storage.googleapis.com/BUCKET?list-type=2&max-keys=1&prefix=ZZZ%2Fstore%2F7b8%2F7b875319-c250-44ae-b878-9c3960ff87a9%2F: Poco::Exception. Code: 1000, e.code() = 0, Timeout, Stack trace (when copying this message, always include the lines below):
    2024.09.25 07:48:01.033525 [ 738891 ] {} <Information> AWSClient: Failed to make request to: https://storage.googleapis.com/BUCKET?list-type=2&max-keys=1&prefix=AAA%2Fstore%2F7b8%2F7b875319-c250-44ae-b878-9c3960ff87a9%2F: Poco::Exception. Code: 1000, e.code() = 0, Timeout, Stack trace (when copying this message, always include the lines below):
    2024.09.25 07:48:01.033990 [ 738891 ] {} <Information> AWSClient: Failed to make request to: https://storage.googleapis.com/BUCKET?list-type=2&max-keys=1&prefix=BBB%2Fstore%2F7b8%2F7b875319-c250-44ae-b878-9c3960ff87a9%2F: Poco::Exception. Code: 1000, e.code() = 101, Net Exception: Network is unreachable, Stack trace (when copying this message, always include the lines below):
    2024.09.25 07:48:02.130098 [ 738891 ] {} <Information> DatabaseCatalog: Removing metadata /srv/clickhouse/metadata_dropped/XXX.YYY.7b875319-c250-44ae-b878-9c3960ff87a9.sql of dropped table XXX.YYY (7b875319-c250-44ae-b878-9c3960ff87a9)
    
  10. alexey-milovidov commented on Nov 22, 2026

    @alexey-milovidov
    Member

    I agree. The implementation is more harmful than what it provides. Will revert.

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

Metadata

Metadata

Assignees

Labels

minorunexpected behaviour

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions