Merge pull request #56609 from jsc0218/LessAggressiveRescheduleWithUnsuccessfulConn

Less aggressive reschedule with unavailable conn of PG
This commit is contained in:
Kseniia Sumarokova 2023-11-13 09:01:23 +01:00 committed by GitHub
commit d3b6310fe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,14 @@ 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;
}