mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Fix table dependencies in case of failed RENAME TABLE
CI found this [1] [ 382620 ] {} <Error> Application: Caught exception while loading metadata: Code: 60. DB::Exception: Table test_25.join doesn\'t exist: While processing _CAST(joinGet(test_25.join, \'m\', CAST(\'42\', \'int\')) AS m_tmp_alter1351896088559986425, \'Int32\') AS m: default expression and column type are incomp [ 382620 ] {} <Error> Application: Code: 60. DB::Exception: Table test_25.join doesn\'t exist: While processing _CAST(joinGet(test_25.join, \'m\', CAST(\'42\', \'int\')) AS m_tmp_alter1351896088559986425, \'Int32\') AS m: default expression and column type are incompatible.: Cannot attach table `test_25`.`t [1]: https://s3.amazonaws.com/clickhouse-test-reports/48670/d7f865037266ed87538cf4df7ec7e8165681871b/stress_test__asan_.html The problem here is that after failed RENAME dependencies got lost: [4e937f39d866] 2023.04.12 00:51:06.833624 [ 13419 ] {61429225-64cb-4fce-b60d-01e0dac6e52c} <Error> executeQuery: Code: 241. DB::Exception: Memory limit (total) exceeded: would use 34.65 GiB (attempt to allocate chunk of 2097419 bytes), maximum: 34.29 GiB. OvercommitTracker decision: Memory overcommit has freed not enough memory. (MEMORY_LIMIT_EXCEEDED) (version 23.4.1.1) (from [::1]:45710) (comment: 01160_table_dependencies.sh) (in query: create database test_25_1), Stack trace (when copying this message, always include the lines below): [4e937f39d866] 2023.04.12 00:51:07.351914 [ 5151 ] {66d8bdd4-668e-4239-a8af-6b8f17bb5222} <Error> executeQuery: Code: 81. DB::Exception: Database test_25_1 doesn't exist. (UNKNOWN_DATABASE) (version 23.4.1.1) (from [::1]:45762) (comment: 01160_table_dependencies.sh) (in query: rename table t to test_25_1.t), Stack trace (when copying this message, always include the lines below): And from the test output: OK OK OK OK a [] [] [] data_02344 [] [] [] date_table [] [] [] dict1 [] ['dict_src'] ['join'] dict2 [] ['join'] [] dict_src [] [] ['dict1'] dist_02346 [] [] [] join [] ['dict1'] ['dict2','s'] ^^^^^^^^^^^^^ no "t" Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
dcfd843b2d
commit
5277c802f7
@ -136,6 +136,8 @@ BlockIO InterpreterRenameQuery::executeToTables(const ASTRenameQuery & rename, c
|
||||
std::tie(ref_dependencies, loading_dependencies) = database_catalog.removeDependencies(from_table_id, check_ref_deps, check_loading_deps);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
database->renameTable(
|
||||
getContext(),
|
||||
elem.from_table_name,
|
||||
@ -146,6 +148,13 @@ BlockIO InterpreterRenameQuery::executeToTables(const ASTRenameQuery & rename, c
|
||||
|
||||
DatabaseCatalog::instance().addDependencies(to_table_id, ref_dependencies, loading_dependencies);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
/// Restore dependencies if RENAME fails
|
||||
DatabaseCatalog::instance().addDependencies(from_table_id, ref_dependencies, loading_dependencies);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -30,6 +30,14 @@ mv [] [] []
|
||||
s [] ['join'] ['t']
|
||||
t ['mv'] ['dict1','join','s'] []
|
||||
OK
|
||||
UNKNOWN_DATABASE
|
||||
dict1 [] ['dict_src'] ['join','t']
|
||||
dict2 [] ['join'] []
|
||||
dict_src [] [] ['dict1']
|
||||
join [] ['dict1'] ['dict2','s','t']
|
||||
mv [] [] []
|
||||
s [] ['join'] ['t']
|
||||
t ['mv'] ['dict1','join','s'] []
|
||||
dict1 [] ['dict_src'] ['join','t']
|
||||
dict2 [] ['join'] []
|
||||
dict_src [] [] ['dict1']
|
||||
|
@ -64,6 +64,10 @@ else
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "rename table t to ${CLICKHOUSE_DATABASE}_2.t" |& grep -m1 -F -o UNKNOWN_DATABASE
|
||||
$CLICKHOUSE_CLIENT -q "select table, arraySort(dependencies_table),
|
||||
arraySort(loading_dependencies_table), arraySort(loading_dependent_table) from system.tables where database in (currentDatabase(), '$t_database') order by table"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "drop table mv"
|
||||
$CLICKHOUSE_CLIENT -q "create database ${CLICKHOUSE_DATABASE}_1"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user