From b5a79b1bdadeb0695c02e8cf6e3999e1e683f941 Mon Sep 17 00:00:00 2001 From: jsc0218 Date: Sat, 11 Nov 2023 02:20:58 +0000 Subject: [PATCH 1/3] less aggressive reschedule when unavailable connection exists, to avoid repeated interrupting other normal routines --- src/Databases/PostgreSQL/DatabasePostgreSQL.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp b/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp index dea05ce19d8..0a7de63942a 100644 --- a/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp +++ b/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp @@ -36,6 +36,7 @@ namespace ErrorCodes static const auto suffix = ".removed"; static const auto cleaner_reschedule_ms = 60000; +static const auto reschedule_error_multiplier = 10; DatabasePostgreSQL::DatabasePostgreSQL( ContextPtr context_, @@ -332,7 +333,13 @@ void DatabasePostgreSQL::removeOutdatedTables() catch (...) { tryLogCurrentException(__PRETTY_FUNCTION__); - cleaner_task->scheduleAfter(cleaner_reschedule_ms); + + /// Avoid repeated interrupting other normal routines (they acquire locks!) + /// for the case of unavailable connection, since it is possible to be + /// unsuccessful again, and the unsuccessful conn is very time-consuming: + /// connection period is exclusive and timeout is at least 2 seconds for + /// PostgreSQL. + cleaner_task->scheduleAfter(reschedule_error_multiplier * cleaner_reschedule_ms); return; } From c63a6f5cf5985ff3d0c80307fe14940b0a9df062 Mon Sep 17 00:00:00 2001 From: jsc0218 Date: Sun, 12 Nov 2023 19:31:38 +0000 Subject: [PATCH 2/3] change comment style --- src/Databases/PostgreSQL/DatabasePostgreSQL.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp b/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp index 0a7de63942a..0fdf8356106 100644 --- a/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp +++ b/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp @@ -334,11 +334,12 @@ void DatabasePostgreSQL::removeOutdatedTables() { tryLogCurrentException(__PRETTY_FUNCTION__); - /// Avoid repeated interrupting other normal routines (they acquire locks!) - /// for the case of unavailable connection, since it is possible to be - /// unsuccessful again, and the unsuccessful conn is very time-consuming: - /// connection period is exclusive and timeout is at least 2 seconds for - /// PostgreSQL. + /** Avoid repeated interrupting other normal routines (they acquire locks!) + * for the case of unavailable connection, since it is possible to be + * unsuccessful again, and the unsuccessful conn is very time-consuming: + * connection period is exclusive and timeout is at least 2 seconds for + * PostgreSQL. + */ cleaner_task->scheduleAfter(reschedule_error_multiplier * cleaner_reschedule_ms); return; } From 9c954046afb31527bd807b134e9592258f83d5a7 Mon Sep 17 00:00:00 2001 From: jsc0218 Date: Sun, 12 Nov 2023 23:23:56 +0000 Subject: [PATCH 3/3] style fix again --- src/Databases/PostgreSQL/DatabasePostgreSQL.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp b/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp index 0fdf8356106..24f04c16029 100644 --- a/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp +++ b/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp @@ -334,10 +334,10 @@ void DatabasePostgreSQL::removeOutdatedTables() { tryLogCurrentException(__PRETTY_FUNCTION__); - /** Avoid repeated interrupting other normal routines (they acquire locks!) - * for the case of unavailable connection, since it is possible to be - * unsuccessful again, and the unsuccessful conn is very time-consuming: - * connection period is exclusive and timeout is at least 2 seconds for + /** Avoid repeated interrupting other normal routines (they acquire locks!) + * for the case of unavailable connection, since it is possible to be + * unsuccessful again, and the unsuccessful conn is very time-consuming: + * connection period is exclusive and timeout is at least 2 seconds for * PostgreSQL. */ cleaner_task->scheduleAfter(reschedule_error_multiplier * cleaner_reschedule_ms);