Repository navigation
DatabaseCatalog drops tables faster - #66065
Conversation
|
This is an automated comment for commit bde1d2f with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
9561d30 to
3a87479
Compare
|
Stress tests (tsan) -- fatal as here #64945 Stateless tests (release) -- Stress test (debug) Stateless Tests (tsan) |
| for (auto it = tables_marked_dropped.begin(); it != tables_marked_dropped.end(); ++it) | ||
| { | ||
| try | ||
| { | ||
| dropTableFinally(table); | ||
| std::lock_guard lock(tables_marked_dropped_mutex); | ||
| [[maybe_unused]] auto removed = tables_marked_dropped_ids.erase(table.table_id.uuid); | ||
| assert(removed); | ||
| } | ||
| catch (...) | ||
| bool in_use = it->table && !it->table.unique(); | ||
| bool old_enough = it->drop_time <= current_time; | ||
| if (!in_use && old_enough) | ||
| result.emplace_back(it); |
There was a problem hiding this comment.
Does it make sense to calculate the number of tables in use and min drop time while iterating through tables here?
There was a problem hiding this comment.
We could, but I was a big confused that we did all that in one iteration like it has a big sense.
I broke it into several iterations to make sure that there is no need to do it on that way.
First iteration -- just take numbers for INFO level logging. That logs are important.
Second iteration -- collect what to drop.
Third iteration -- seeing actual data after collected tables are dropped we decide when it has to be rescheduled.
|
I need the same logic when I erase iterator from list |
|
Stateless Tests (debug, S3 Storage) -- Stateless Tests (debug) [2/2] -- there no expected logs, strange |
|
This approach does not allows to scale DROP queries properly, it can only remove tables concurrently if the were lucky and end up in one batch |
Right now for instance 01825_type_json_ghdata breaks other tests [1], part of the problem is that DROP does not scale [2], but another is that this test is not light weight. [1]: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=04393dc83405d1fc726f80ec472f145d8ec235e7&name_0=MasterCI&name_1=Stateless%20tests%20%28azure%2C%20asan%2C%201%2F3%29 [2]: ClickHouse#66065 (comment)
|
Hi @CheSema @tavplubix — while reviewing this PR I found the following:
Happy to discuss — close anything that's wrong or already addressed. |
|
Update on the earlier review: CI on the proof PR #104904 confirmed the suspected bug via
(Automated follow-up. The proof PR has been closed; please track the bug on the Issue.) |
`getTablesToDrop` returned iterators into `tables_marked_dropped` under the mutex, but the mutex was released before `dropTablesParallel` consumed them, so a concurrent `undropTable` could erase entries and leave the drop jobs holding dangling iterators — see ClickHouse#66065. `getTablesToDrop` now splices eligible entries out of `tables_marked_dropped` under the mutex and returns the private list by value; in-flight tables are invisible to `undropTable`. `dropTablesParallel` owns the list, never mutates it (moved-from entries die with the list), and on failure moves the entry back into `tables_marked_dropped` via `emplace_back` — splicing back would race with the main loop iterating `tables_to_drop`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
DatabaseCatalog drops tables faster by using up to database_catalog_drop_table_concurrency threads
Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):