Skip to content

Commit 0401dc4

Browse files
committed
Fix flakiness of test_version_update_after_mutation by enabling force_remove_data_recursively_on_drop
Since there can be some leftovers: 2023.07.24 07:08:25.238066 [ 140 ] {} <Error> Application: Code: 219. DB::Exception: Cannot drop: filesystem error: in remove: Directory not empty ["/var/lib/clickhouse/data/system/"]. Probably database contain some detached tables or metadata leftovers from Ordinary engine. If you want to remove all data anyway, try to attach database back and drop it again with enabled force_remove_data_recursively_on_drop setting: Exception while trying to convert database system from Ordinary to Atomic. It may be in some intermediate state. You can finish conversion manually by moving the rest tables from system to .tmp_convert.system.9396432095832455195 (using RENAME TABLE) and executing DROP DATABASE system and RENAME DATABASE .tmp_convert.system.9396432095832455195 TO system. (DATABASE_NOT_EMPTY), Stack trace (when copying this message, always include the lines below): 0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000e68af57 in /usr/bin/clickhouse 1. ? @ 0x000000000cab443c in /usr/bin/clickhouse 2. DB::DatabaseOnDisk::drop(std::shared_ptr<DB::Context const>) @ 0x000000001328d617 in /usr/bin/clickhouse 3. DB::DatabaseCatalog::detachDatabase(std::shared_ptr<DB::Context const>, String const&, bool, bool) @ 0x0000000013524a6c in /usr/bin/clickhouse 4. DB::InterpreterDropQuery::executeToDatabaseImpl(DB::ASTDropQuery const&, std::shared_ptr<DB::IDatabase>&, std::vector<StrongTypedef<wide::integer<128ul, unsigned int>, DB::UUIDTag>, std::allocator<StrongTypedef<wide::integer<128ul, unsigned int>, DB::UUIDTag>>>&) @ 0x0000000013bc05e4 in /usr/bin/clickhouse 5. DB::InterpreterDropQuery::executeToDatabase(DB::ASTDropQuery const&) @ 0x0000000013bbc6b8 in /usr/bin/clickhouse 6. DB::InterpreterDropQuery::execute() @ 0x0000000013bbba22 in /usr/bin/clickhouse 7. ? @ 0x00000000140b13a5 in /usr/bin/clickhouse 8. DB::executeQuery(String const&, std::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) @ 0x00000000140ad20e in /usr/bin/clickhouse 9. ? @ 0x00000000140d2ef0 in /usr/bin/clickhouse 10. DB::maybeConvertSystemDatabase(std::shared_ptr<DB::Context>) @ 0x00000000140d0aaf in /usr/bin/clickhouse 11. DB::Server::main(std::vector<String, std::allocator<String>> const&) @ 0x000000000e724e55 in /usr/bin/clickhouse 12. Poco::Util::Application::run() @ 0x0000000017ead086 in /usr/bin/clickhouse 13. DB::Server::run() @ 0x000000000e714a5d in /usr/bin/clickhouse 14. Poco::Util::ServerApplication::run(int, char**) @ 0x0000000017ec07b9 in /usr/bin/clickhouse 15. mainEntryClickHouseServer(int, char**) @ 0x000000000e711a26 in /usr/bin/clickhouse 16. main @ 0x0000000008cf13cf in /usr/bin/clickhouse 17. __libc_start_main @ 0x0000000000021b97 in /lib/x86_64-linux-gnu/libc-2.27.so 18. _start @ 0x00000000080705ae in /usr/bin/clickhouse (version 23.7.1.2012) Signed-off-by: Azat Khuzhin <[email protected]>
1 parent f17844e commit 0401dc4

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

tests/integration/helpers/cluster.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,6 +3199,7 @@ def __init__(
31993199
):
32003200
self.name = name
32013201
self.base_cmd = cluster.base_cmd
3202+
self.base_dir = base_path
32023203
self.docker_id = cluster.get_instance_docker_id(self.name)
32033204
self.cluster = cluster
32043205
self.hostname = hostname if hostname is not None else self.name
@@ -4193,6 +4194,14 @@ def replace_in_config(self, path_to_config, replace, replacement):
41934194
["bash", "-c", f"sed -i 's/{replace}/{replacement}/g' {path_to_config}"]
41944195
)
41954196

4197+
def put_users_config(self, config_path):
4198+
"""Put new config (useful if you cannot put it at the start)"""
4199+
4200+
instance_config_dir = p.abspath(p.join(self.path, "configs"))
4201+
users_d_dir = p.abspath(p.join(instance_config_dir, "users.d"))
4202+
config_path = p.join(self.base_dir, config_path)
4203+
shutil.copy(config_path, users_d_dir)
4204+
41964205
def create_dir(self):
41974206
"""Create the instance directory and all the needed files there."""
41984207

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<clickhouse>
2+
<profiles>
3+
<default>
4+
<force_remove_data_recursively_on_drop>1</force_remove_data_recursively_on_drop>
5+
</default>
6+
</profiles>
7+
</clickhouse>

tests/integration/test_version_update_after_mutation/test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def start_cluster():
5151
cluster.shutdown()
5252

5353

54+
def restart_node(node):
55+
# set force_remove_data_recursively_on_drop (cannot be done before, because the version is too old)
56+
node.put_users_config("configs/force_remove_data_recursively_on_drop.xml")
57+
node.restart_with_latest_version(signal=9, fix_metadata=True)
58+
59+
5460
def test_mutate_and_upgrade(start_cluster):
5561
for node in [node1, node2]:
5662
node.query("DROP TABLE IF EXISTS mt")
@@ -67,8 +73,9 @@ def test_mutate_and_upgrade(start_cluster):
6773

6874
node2.query("DETACH TABLE mt") # stop being leader
6975
node1.query("DETACH TABLE mt") # stop being leader
70-
node1.restart_with_latest_version(signal=9, fix_metadata=True)
71-
node2.restart_with_latest_version(signal=9, fix_metadata=True)
76+
77+
restart_node(node1)
78+
restart_node(node2)
7279

7380
# After hard restart table can be in readonly mode
7481
exec_query_with_retry(
@@ -124,7 +131,7 @@ def test_upgrade_while_mutation(start_cluster):
124131
# (We could be in process of creating some system table, which will leave empty directory on restart,
125132
# so when we start moving system tables from ordinary to atomic db, it will complain about some undeleted files)
126133
node3.query("SYSTEM FLUSH LOGS")
127-
node3.restart_with_latest_version(signal=9, fix_metadata=True)
134+
restart_node(node3)
128135

129136
# checks for readonly
130137
exec_query_with_retry(node3, "OPTIMIZE TABLE mt1", sleep_time=5, retry_count=60)

0 commit comments

Comments
 (0)