fix(build): adapt callers of dns_cache counters to std::atomic

The previous commit promoted MySQL_Monitor::dns_cache_{queried,
lookup_success,record_updated} to std::atomic<unsigned long long>
but missed several call sites that pass them through implicit copy:

* lib/MySQL_Thread.cpp sprintf("%llu", GloMyMon->dns_cache_*) — varargs
  cannot copy std::atomic.
* lib/PgSQL_Thread.cpp sprintf("%llu", GloPgMon->dns_cache_*) — same,
  for the PgSQL counters.
* lib/MySQL_Monitor.cpp p_update_counter(..., GloMyMon->dns_cache_*) —
  works via implicit operator T(), but explicit .load() is clearer
  and matches the rest of the file.

Promote PgSQL_Monitor::dns_cache_* to std::atomic for the same race
that motivated the MySQL side (resolver workers increment, stats
readers and p_update_metrics read from another thread), and add
.load() at every read site so we don't depend on implicit conversion.

Verified with a local 'make -j32 debug' build in the integration
worktree.
fix/kill-proxysqlgenai-build-flag
Rene Cannao 1 month ago
parent 160c8ed3a2
commit 031f6fa1f5

@ -50,10 +50,12 @@ struct PgSQL_Monitor {
uint64_t repl_lag_check_OK { 0 };
uint64_t ssl_connections_OK { 0 };
uint64_t non_ssl_connections_OK { 0 };
// DNS cache counters (independent of MySQL_Monitor's counters)
unsigned long long dns_cache_queried { 0 };
unsigned long long dns_cache_lookup_success { 0 };
unsigned long long dns_cache_record_updated { 0 };
// DNS cache counters (independent of MySQL_Monitor's counters). Atomic
// because the resolver workers increment them while readers (stats,
// p_update_metrics) load them from other threads.
std::atomic<unsigned long long> dns_cache_queried { 0 };
std::atomic<unsigned long long> dns_cache_lookup_success { 0 };
std::atomic<unsigned long long> dns_cache_record_updated { 0 };
///////////////////////////////////////////////////////////////////////////
// PgSQL-side DNS cache, independent of MySQL_Monitor's cache. Lifetime is

@ -1204,9 +1204,9 @@ void MySQL_Monitor::p_update_metrics() {
p_update_counter(this->metrics.p_counter_array[p_mon_counter::mysql_monitor_read_only_check_err], GloMyMon->read_only_check_ERR);
p_update_counter(this->metrics.p_counter_array[p_mon_counter::mysql_monitor_replication_lag_check_ok], GloMyMon->replication_lag_check_OK);
p_update_counter(this->metrics.p_counter_array[p_mon_counter::mysql_monitor_replication_lag_check_err], GloMyMon->replication_lag_check_ERR);
p_update_counter(this->metrics.p_counter_array[p_mon_counter::mysql_monitor_dns_cache_queried], GloMyMon->dns_cache_queried);
p_update_counter(this->metrics.p_counter_array[p_mon_counter::mysql_monitor_dns_cache_lookup_success], GloMyMon->dns_cache_lookup_success);
p_update_counter(this->metrics.p_counter_array[p_mon_counter::mysql_monitor_dns_cache_record_updated], GloMyMon->dns_cache_record_updated);
p_update_counter(this->metrics.p_counter_array[p_mon_counter::mysql_monitor_dns_cache_queried], GloMyMon->dns_cache_queried.load());
p_update_counter(this->metrics.p_counter_array[p_mon_counter::mysql_monitor_dns_cache_lookup_success], GloMyMon->dns_cache_lookup_success.load());
p_update_counter(this->metrics.p_counter_array[p_mon_counter::mysql_monitor_dns_cache_record_updated], GloMyMon->dns_cache_record_updated.load());
}
}

@ -5336,19 +5336,19 @@ SQLite3_result * MySQL_Threads_Handler::SQL3_GlobalStatus(bool _memory) {
}
{
pta[0] = (char*)"MySQL_Monitor_dns_cache_queried";
sprintf(buf, "%llu", GloMyMon->dns_cache_queried);
sprintf(buf, "%llu", GloMyMon->dns_cache_queried.load());
pta[1] = buf;
result->add_row(pta);
}
{
pta[0] = (char*)"MySQL_Monitor_dns_cache_lookup_success";
sprintf(buf, "%llu", GloMyMon->dns_cache_lookup_success);
sprintf(buf, "%llu", GloMyMon->dns_cache_lookup_success.load());
pta[1] = buf;
result->add_row(pta);
}
{
pta[0] = (char*)"MySQL_Monitor_dns_cache_record_updated";
sprintf(buf, "%llu", GloMyMon->dns_cache_record_updated);
sprintf(buf, "%llu", GloMyMon->dns_cache_record_updated.load());
pta[1] = buf;
result->add_row(pta);
}

@ -4760,19 +4760,19 @@ SQLite3_result* PgSQL_Threads_Handler::SQL3_GlobalStatus(bool _memory) {
}
{
pta[0] = (char*)"PgSQL_Monitor_dns_cache_queried";
sprintf(buf, "%llu", GloPgMon->dns_cache_queried);
sprintf(buf, "%llu", GloPgMon->dns_cache_queried.load());
pta[1] = buf;
result->add_row(pta);
}
{
pta[0] = (char*)"PgSQL_Monitor_dns_cache_lookup_success";
sprintf(buf, "%llu", GloPgMon->dns_cache_lookup_success);
sprintf(buf, "%llu", GloPgMon->dns_cache_lookup_success.load());
pta[1] = buf;
result->add_row(pta);
}
{
pta[0] = (char*)"PgSQL_Monitor_dns_cache_record_updated";
sprintf(buf, "%llu", GloPgMon->dns_cache_record_updated);
sprintf(buf, "%llu", GloPgMon->dns_cache_record_updated.load());
pta[1] = buf;
result->add_row(pta);
}

Loading…
Cancel
Save