Merge pull request #5192 from sysown/v3.0_add_delay_watchdog

Improved PgSQL/MySQL Thread Watchdog Unit Test
pull/5198/head
René Cannaò 5 months ago committed by GitHub
commit c06e15fd74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -3394,8 +3394,9 @@ __run_skip_1:
#ifdef DEBUG
// This block is only used for Watchdog unit tests:
// Specifically for PROXYSQLTEST cases 55 0 and 55 1.
if (watchdog_test__simulated_delay_ms)
std::this_thread::sleep_for(std::chrono::milliseconds(watchdog_test__simulated_delay_ms));
while (watchdog_test__simulated_delay_ms > 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
#endif
}
}

@ -3192,8 +3192,9 @@ void PgSQL_Thread::run() {
#ifdef DEBUG
// This block is only used for Watchdog unit tests:
// Specifically for PROXYSQLTEST cases 55 0 and 55 1.
if (watchdog_test__simulated_delay_ms)
std::this_thread::sleep_for(std::chrono::milliseconds(watchdog_test__simulated_delay_ms));
while (watchdog_test__simulated_delay_ms > 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
#endif
}
}

@ -550,13 +550,13 @@ bool RunWatchdogTest(const char* label, ThreadType* worker, unsigned int poll_ti
return false;
}
proxy_info("Starting Watchdog test for %s threads...\n", label);
proxy_info("Starting Watchdog test for %s threads (poll timeout:%u ms)...\n", label, poll_timeout);
const unsigned int target_missed = GloVars.restart_on_missing_heartbeats;
const uint64_t time_per_miss_ms = poll_timeout + 1000 + 200;
const uint64_t total_expected_time_ms = target_missed * time_per_miss_ms;
const unsigned int time_per_miss_ms = poll_timeout + 1000 + 200;
const unsigned int total_expected_time_ms = target_missed * time_per_miss_ms;
worker->watchdog_test__simulated_delay_ms = static_cast<unsigned int>(total_expected_time_ms);
worker->watchdog_test__simulated_delay_ms = total_expected_time_ms;
const unsigned int timeout_ms = static_cast<unsigned int>(total_expected_time_ms * 1.25);
constexpr unsigned int poll_interval_ms = 200;
@ -571,7 +571,7 @@ bool RunWatchdogTest(const char* label, ThreadType* worker, unsigned int poll_ti
unsigned int missed = worker->watchdog_test__missed_heartbeats;
if (missed != last_missed) {
last_missed = missed;
proxy_info("Watchdog test: Missed heartbeats: %u\n", missed);
proxy_info("Watchdog test - Missed heartbeats: %u\n", missed);
}
if (success == false && missed == target_missed) {
@ -584,6 +584,13 @@ bool RunWatchdogTest(const char* label, ThreadType* worker, unsigned int poll_ti
worker->watchdog_test__simulated_delay_ms = 0;
worker->watchdog_test__missed_heartbeats = 0;
usleep(1000000);
if (worker->watchdog_test__missed_heartbeats != 0) {
worker->watchdog_test__simulated_delay_ms = 0;
worker->watchdog_test__missed_heartbeats = 0;
}
if (success) {
proxy_info("Watchdog test passed. Missed heartbeats: %u\n", target_missed);
} else {

Loading…
Cancel
Save