Revert "Un-flake test_undrop_query"

This commit is contained in:
Robert Schulze 2024-03-20 18:04:35 +01:00 committed by GitHub
parent 4f51d891a0
commit 35cc335597
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 48 additions and 45 deletions

View File

@ -933,9 +933,9 @@ Hard limit is configured via system tools
## database_atomic_delay_before_drop_table_sec {#database_atomic_delay_before_drop_table_sec}
The delay before a table data is dropped in seconds. If the `DROP TABLE` query has a `SYNC` modifier, this setting is ignored.
Sets the delay before remove table data in seconds. If the query has `SYNC` modifier, this setting is ignored.
Default value: `480` (8 minutes).
Default value: `480` (8 minute).
## database_catalog_unused_dir_hide_timeout_sec {#database_catalog_unused_dir_hide_timeout_sec}

View File

@ -13,6 +13,13 @@ a system table called `system.dropped_tables`.
If you have a materialized view without a `TO` clause associated with the dropped table, then you will also have to UNDROP the inner table of that view.
:::note
UNDROP TABLE is experimental. To use it add this setting:
```sql
set allow_experimental_undrop_table_query = 1;
```
:::
:::tip
Also see [DROP TABLE](/docs/en/sql-reference/statements/drop.md)
:::
@ -25,53 +32,60 @@ UNDROP TABLE [db.]name [UUID '<uuid>'] [ON CLUSTER cluster]
**Example**
``` sql
set allow_experimental_undrop_table_query = 1;
```
```sql
CREATE TABLE tab
CREATE TABLE undropMe
(
`id` UInt8
)
ENGINE = MergeTree
ORDER BY id;
DROP TABLE tab;
SELECT *
FROM system.dropped_tables
FORMAT Vertical;
ORDER BY id
```
```sql
DROP TABLE undropMe
```
```sql
SELECT *
FROM system.dropped_tables
FORMAT Vertical
```
```response
Row 1:
──────
index: 0
database: default
table: tab
table: undropMe
uuid: aa696a1a-1d70-4e60-a841-4c80827706cc
engine: MergeTree
metadata_dropped_path: /var/lib/clickhouse/metadata_dropped/default.tab.aa696a1a-1d70-4e60-a841-4c80827706cc.sql
metadata_dropped_path: /var/lib/clickhouse/metadata_dropped/default.undropMe.aa696a1a-1d70-4e60-a841-4c80827706cc.sql
table_dropped_time: 2023-04-05 14:12:12
1 row in set. Elapsed: 0.001 sec.
```
```sql
UNDROP TABLE tab;
UNDROP TABLE undropMe
```
```response
Ok.
```
```sql
SELECT *
FROM system.dropped_tables
FORMAT Vertical;
FORMAT Vertical
```
```response
Ok.
0 rows in set. Elapsed: 0.001 sec.
```
```sql
DESCRIBE TABLE tab
FORMAT Vertical;
DESCRIBE TABLE undropMe
FORMAT Vertical
```
```response
Row 1:
──────

View File

@ -1142,7 +1142,7 @@ void DatabaseCatalog::dequeueDroppedTableCleanup(StorageID table_id)
TableMarkedAsDropped dropped_table;
{
std::lock_guard lock(tables_marked_dropped_mutex);
auto latest_drop_time = std::numeric_limits<time_t>::min();
time_t latest_drop_time = std::numeric_limits<time_t>::min();
auto it_dropped_table = tables_marked_dropped.end();
for (auto it = tables_marked_dropped.begin(); it != tables_marked_dropped.end(); ++it)
{
@ -1167,7 +1167,7 @@ void DatabaseCatalog::dequeueDroppedTableCleanup(StorageID table_id)
}
if (it_dropped_table == tables_marked_dropped.end())
throw Exception(ErrorCodes::UNKNOWN_TABLE,
"Table {} is being dropped, has been dropped, or the database engine does not support UNDROP",
"The drop task of table {} is in progress, has been dropped or the database engine doesn't support it",
table_id.getNameForLogs());
latest_metadata_dropped_path = it_dropped_table->metadata_path;
String table_metadata_path = getPathForMetadata(it_dropped_table->table_id);

View File

@ -17,16 +17,14 @@ namespace ErrorCodes
extern const int SUPPORT_IS_DISABLED;
}
InterpreterUndropQuery::InterpreterUndropQuery(const ASTPtr & query_ptr_, ContextMutablePtr context_)
: WithMutableContext(context_)
, query_ptr(query_ptr_)
InterpreterUndropQuery::InterpreterUndropQuery(const ASTPtr & query_ptr_, ContextMutablePtr context_) : WithMutableContext(context_), query_ptr(query_ptr_)
{
}
BlockIO InterpreterUndropQuery::execute()
{
getContext()->checkAccess(AccessType::UNDROP_TABLE);
auto & undrop = query_ptr->as<ASTUndropQuery &>();
if (!undrop.cluster.empty() && !maybeRemoveOnCluster(query_ptr, getContext()))
{

View File

@ -29,39 +29,30 @@ def test_undrop_drop_and_undrop_loop(started_cluster):
logging.info(
"random_sec: " + random_sec.__str__() + ", table_uuid: " + table_uuid
)
node.query(
"CREATE TABLE test_undrop_loop"
"create table test_undrop_loop"
+ count.__str__()
+ " UUID '"
+ table_uuid
+ "' (id Int32) ENGINE = MergeTree() ORDER BY id;"
+ "' (id Int32) Engine=MergeTree() order by id;"
)
node.query("DROP TABLE test_undrop_loop" + count.__str__() + ";")
node.query("drop table test_undrop_loop" + count.__str__() + ";")
time.sleep(random_sec)
if random_sec >= 5:
error = node.query_and_get_error(
"UNDROP TABLE test_undrop_loop"
"undrop table test_undrop_loop"
+ count.__str__()
+ " UUID '"
+ " uuid '"
+ table_uuid
+ "';"
)
assert "UNKNOWN_TABLE" in error
elif random_sec <= 3:
# (*)
else:
node.query(
"UNDROP TABLE test_undrop_loop"
"undrop table test_undrop_loop"
+ count.__str__()
+ " UUID '"
+ " uuid '"
+ table_uuid
+ "';"
)
count = count + 1
else:
pass
# ignore random_sec = 4 to account for communication delay with the database.
# if we don't do that, then the second case (*) may find the table already dropped and receive an unexpected exception from the database (Bug #55167)

View File

@ -85,5 +85,5 @@ drop table 02681_undrop_multiple;
select table from system.dropped_tables where table = '02681_undrop_multiple' limit 1;
undrop table 02681_undrop_multiple;
select * from 02681_undrop_multiple order by id;
undrop table 02681_undrop_multiple; -- { serverError TABLE_ALREADY_EXISTS }
undrop table 02681_undrop_multiple; -- { serverError 57 }
drop table 02681_undrop_multiple sync;