1) Extend stop_start_wait_sec and reduce connection_timeout_ms in

test_replicated_database when restarting an instance.
2) Make createReplicaDirs and markReplicasActive virtual functions
This commit is contained in:
Tuan Pham Anh 2024-10-02 11:55:26 +00:00
parent 743ffeba25
commit 6413b15d81
7 changed files with 30 additions and 13 deletions

View File

@ -41,6 +41,10 @@ public:
private:
bool initializeMainThread() override;
void initializeReplication() override;
void createReplicaDirs(const ZooKeeperPtr &, const NameSet &) override { }
void markReplicasActive(bool) override { }
void initializeLogPointer(const String & processed_entry_name);
DDLTaskPtr initAndCheckTask(const String & entry_name, String & out_reason, const ZooKeeperPtr & zookeeper) override;

View File

@ -1176,7 +1176,14 @@ void DDLWorker::runMainThread()
}
cleanup_event->set();
markReplicasActive(reinitialized);
try
{
markReplicasActive(reinitialized);
}
catch (...)
{
tryLogCurrentException(log, "An error occurred when markReplicasActive: ");
}
scheduleTasks(reinitialized);
subsequent_errors_count = 0;

View File

@ -158,8 +158,8 @@ protected:
virtual bool initializeMainThread();
virtual void initializeReplication();
void createReplicaDirs(const ZooKeeperPtr & zookeeper, const NameSet & host_ids);
void markReplicasActive(bool reinitialized);
virtual void createReplicaDirs(const ZooKeeperPtr & zookeeper, const NameSet & host_ids);
virtual void markReplicasActive(bool reinitialized);
void runMainThread();
void runCleanupThread();

View File

@ -4028,11 +4028,11 @@ class ClickHouseInstance:
)
logging.info(f"PS RESULT:\n{ps_clickhouse}")
pid = self.get_process_pid("clickhouse")
if pid is not None:
self.exec_in_container(
["bash", "-c", f"gdb -batch -ex 'thread apply all bt full' -p {pid}"],
user="root",
)
# if pid is not None:
# self.exec_in_container(
# ["bash", "-c", f"gdb -batch -ex 'thread apply all bt full' -p {pid}"],
# user="root",
# )
if last_err is not None:
raise last_err

View File

@ -7,4 +7,7 @@
<max_database_replicated_create_table_thread_pool_size>50</max_database_replicated_create_table_thread_pool_size>
<allow_experimental_transactions>42</allow_experimental_transactions>
<async_load_databases>false</async_load_databases>
<zookeeper>
<connection_timeout_ms>200</connection_timeout_ms>
</zookeeper>
</clickhouse>

View File

@ -8,4 +8,7 @@
<allow_experimental_transactions>42</allow_experimental_transactions>
<replica_group_name>group</replica_group_name>
<async_load_databases>false</async_load_databases>
<zookeeper>
<connection_timeout_ms>200</connection_timeout_ms>
</zookeeper>
</clickhouse>

View File

@ -617,7 +617,7 @@ def test_alters_from_different_replicas(started_cluster):
)
# test_replica_restart
main_node.restart_clickhouse()
main_node.restart_clickhouse(stop_start_wait_sec=120)
expected = (
"CREATE TABLE alters_from_different_replicas.concurrent_test\\n(\\n `CounterID` UInt32,\\n `StartDate` Date,\\n `UserID` UInt32,\\n"
@ -1125,7 +1125,7 @@ def test_startup_without_zk(started_cluster):
main_node.query("INSERT INTO startup.rmt VALUES (42)")
with PartitionManager() as pm:
pm.drop_instance_zk_connections(main_node)
main_node.restart_clickhouse(stop_start_wait_sec=60)
main_node.restart_clickhouse(stop_start_wait_sec=120)
assert main_node.query("SELECT (*,).1 FROM startup.rmt") == "42\n"
# we need to wait until the table is not readonly
@ -1143,7 +1143,7 @@ def test_server_uuid(started_cluster):
uuid1 = main_node.query("select serverUUID()")
uuid2 = dummy_node.query("select serverUUID()")
assert uuid1 != uuid2
main_node.restart_clickhouse()
main_node.restart_clickhouse(stop_start_wait_sec=120)
uuid1_after_restart = main_node.query("select serverUUID()")
assert uuid1 == uuid1_after_restart
@ -1408,14 +1408,14 @@ def test_modify_comment(started_cluster):
)
def restart_verify_not_readonly():
main_node.restart_clickhouse()
main_node.restart_clickhouse(stop_start_wait_sec=120)
assert (
main_node.query(
"SELECT is_readonly FROM system.replicas WHERE table = 'modify_comment_table'"
)
== "0\n"
)
dummy_node.restart_clickhouse()
dummy_node.restart_clickhouse(stop_start_wait_sec=120)
assert (
dummy_node.query(
"SELECT is_readonly FROM system.replicas WHERE table = 'modify_comment_table'"