Add complete PostgreSQL variables cluster synchronization including:
- CLUSTER_QUERY_PGSQL_VARIABLES constant definition
- pull_pgsql_variables_from_peer() function implementation
- PostgreSQL variables sync decision logic in cluster sync loop
- Comprehensive error handling and metrics integration
- Runtime loading and save-to-disk support
- Interface filtering for cluster_sync_interfaces=false
This addresses the critical gap where PostgreSQL variables were not
being synchronized between ProxySQL cluster nodes, completing the
PostgreSQL module integration into the unified cluster architecture.
#define CLUSTER_QUERY_PGSQL_QUERY_RULES_FAST_ROUTING "PROXY_SELECT username, database, flagIN, destination_hostgroup, comment FROM runtime_pgsql_query_rules_fast_routing ORDER BY username, database, flagIN"
#define CLUSTER_QUERY_PGSQL_VARIABLES "PROXY_SELECT variable_name, variable_value FROM runtime_pgsql_variables ORDER BY variable_name"
proxy_debug(PROXY_DEBUG_CLUSTER,5,"Detected peer %s:%d with pgsql_variables version %llu, epoch %llu, diff_check %u. Own version: %llu, epoch: %llu. Proceeding with remote sync\n",hostname,port,v->version,v->epoch,v->diff_check,own_version,own_epoch);
proxy_info("Cluster: detected a peer %s:%d with pgsql_variables version %llu, epoch %llu, diff_check %u. Own version: %llu, epoch: %llu. Proceeding with remote sync\n",hostname,port,v->version,v->epoch,v->diff_check,own_version,own_epoch);
proxy_debug(PROXY_DEBUG_CLUSTER,5,"Detected peer %s:%d with pgsql_variables version %llu, epoch %llu, diff_check %u, checksum %s. Own version: %llu, epoch: %llu, checksum %s. Sync conflict, epoch times are EQUAL, can't determine which server holds the latest config, we won't sync. This message will be repeated every %u checks until LOAD PGSQL VARIABLES TO RUNTIME is executed on candidate master.\n",hostname,port,v->version,v->epoch,v->diff_check,v->checksum,own_version,own_epoch,own_checksum,(diff_mv_pgsql*10));
proxy_error("Cluster: detected a peer %s:%d with pgsql_variables version %llu, epoch %llu, diff_check %u, checksum %s. Own version: %llu, epoch: %llu, checksum %s. Sync conflict, epoch times are EQUAL, can't determine which server holds the latest config, we won't sync. This message will be repeated every %u checks until LOAD PGSQL VARIABLES TO RUNTIME is executed on candidate master.\n",hostname,port,v->version,v->epoch,v->diff_check,v->checksum,own_version,own_epoch,own_checksum,(diff_mv_pgsql*10));
proxy_debug(PROXY_DEBUG_CLUSTER,5,"Detected a peer %s:%d with pgsql_variables version %llu, epoch %llu, diff_check %u. Own version: %llu, epoch: %llu. diff_check is increasing, but version 1 doesn't allow sync. This message will be repeated every %u checks until LOAD PGSQL VARIABLES TO RUNTIME is executed on candidate master.\n",hostname,port,v->version,v->epoch,v->diff_check,own_version,own_epoch,(diff_mv_pgsql*10));
proxy_warning("Cluster: detected a peer %s:%d with pgsql_variables version %llu, epoch %llu, diff_check %u. Own version: %llu, epoch: %llu. diff_check is increasing, but version 1 doesn't allow sync. This message will be repeated every %u checks until LOAD PGSQL VARIABLES TO RUNTIME is executed on candidate master.\n",hostname,port,v->version,v->epoch,v->diff_check,own_version,own_epoch,(diff_mv_pgsql*10));