fix: correct PostgreSQL cluster sync architecture by removing separate module infrastructure

- Remove incorrect separate module declarations for pgsql_replication_hostgroups and pgsql_hostgroup_attributes from ProxySQL_Cluster.hpp
- Remove separate module counter enums and atomic variables
- Remove separate module metrics definitions and configurations
- Remove incorrect admin variable implementations for non-distinct modules
- Verify that PostgreSQL tables correctly sync as part of unified pgsql_servers module
- Confirm build succeeds and no remaining references to removed infrastructure

These tables are part of the pgsql_servers module and should not be treated as
separate modules. The PgSQL_HostGroups_Manager::commit_update_checksums_from_tables()
function already correctly includes both tables in the unified checksum computation.

Resolves the architectural error where separate module infrastructure was added
for tables that are not distinct modules.
fix/postgresql-cluster-sync_2
Rene Cannao 4 months ago
parent f9e3e85e68
commit b177750242

@ -316,8 +316,6 @@ class ProxySQL_Node_Entry {
ProxySQL_Checksum_Value_2 pgsql_users;
ProxySQL_Checksum_Value_2 pgsql_servers_v2;
ProxySQL_Checksum_Value_2 pgsql_variables;
ProxySQL_Checksum_Value_2 pgsql_replication_hostgroups;
ProxySQL_Checksum_Value_2 pgsql_hostgroup_attributes;
} checksums_values;
uint64_t global_checksum;
};
@ -471,11 +469,6 @@ struct p_cluster_counter {
pulled_pgsql_variables_success,
pulled_pgsql_variables_failure,
pulled_pgsql_replication_hostgroups_success,
pulled_pgsql_replication_hostgroups_failure,
pulled_pgsql_hostgroup_attributes_success,
pulled_pgsql_hostgroup_attributes_failure,
pulled_mysql_ldap_mapping_success,
pulled_mysql_ldap_mapping_failure,
@ -490,8 +483,6 @@ struct p_cluster_counter {
sync_conflict_pgsql_servers_share_epoch,
sync_conflict_pgsql_users_share_epoch,
sync_conflict_pgsql_variables_share_epoch,
sync_conflict_pgsql_replication_hostgroups_share_epoch,
sync_conflict_pgsql_hostgroup_attributes_share_epoch,
sync_delayed_mysql_query_rules_version_one,
sync_delayed_mysql_servers_version_one,
@ -501,8 +492,6 @@ struct p_cluster_counter {
sync_delayed_admin_variables_version_one,
sync_delayed_ldap_variables_version_one,
sync_delayed_pgsql_variables_version_one,
sync_delayed_pgsql_replication_hostgroups_version_one,
sync_delayed_pgsql_hostgroup_attributes_version_one,
__size
};
@ -616,8 +605,6 @@ public:
std::atomic<int> cluster_pgsql_servers_diffs_before_sync;
std::atomic<int> cluster_pgsql_users_diffs_before_sync;
std::atomic<int> cluster_pgsql_variables_diffs_before_sync;
std::atomic<int> cluster_pgsql_replication_hostgroups_diffs_before_sync;
std::atomic<int> cluster_pgsql_hostgroup_attributes_diffs_before_sync;
int cluster_mysql_servers_sync_algorithm;
bool cluster_mysql_query_rules_save_to_disk;
bool cluster_mysql_servers_save_to_disk;
@ -630,8 +617,6 @@ public:
bool cluster_pgsql_servers_save_to_disk;
bool cluster_pgsql_users_save_to_disk;
bool cluster_pgsql_variables_save_to_disk;
bool cluster_pgsql_replication_hostgroups_save_to_disk;
bool cluster_pgsql_hostgroup_attributes_save_to_disk;
ProxySQL_Cluster();
~ProxySQL_Cluster();
void init() {};

@ -317,8 +317,6 @@ class ProxySQL_Admin {
int cluster_pgsql_query_rules_diffs_before_sync;
int cluster_pgsql_servers_diffs_before_sync;
int cluster_pgsql_users_diffs_before_sync;
int cluster_pgsql_replication_hostgroups_diffs_before_sync;
int cluster_pgsql_hostgroup_attributes_diffs_before_sync;
int cluster_mysql_servers_sync_algorithm;
bool cluster_mysql_query_rules_save_to_disk;
bool cluster_mysql_servers_save_to_disk;
@ -331,8 +329,6 @@ class ProxySQL_Admin {
bool cluster_pgsql_query_rules_save_to_disk;
bool cluster_pgsql_servers_save_to_disk;
bool cluster_pgsql_users_save_to_disk;
bool cluster_pgsql_replication_hostgroups_save_to_disk;
bool cluster_pgsql_hostgroup_attributes_save_to_disk;
int stats_mysql_connection_pool;
int stats_mysql_connections;
int stats_mysql_query_cache;

@ -392,8 +392,6 @@ static char * admin_variables_names[]= {
(char *)"cluster_pgsql_query_rules_diffs_before_sync",
(char *)"cluster_pgsql_servers_diffs_before_sync",
(char *)"cluster_pgsql_users_diffs_before_sync",
(char *)"cluster_pgsql_replication_hostgroups_diffs_before_sync",
(char *)"cluster_pgsql_hostgroup_attributes_diffs_before_sync",
(char *)"cluster_mysql_query_rules_save_to_disk",
(char *)"cluster_mysql_servers_save_to_disk",
(char *)"cluster_mysql_users_save_to_disk",
@ -405,8 +403,6 @@ static char * admin_variables_names[]= {
(char *)"cluster_pgsql_query_rules_save_to_disk",
(char *)"cluster_pgsql_servers_save_to_disk",
(char *)"cluster_pgsql_users_save_to_disk",
(char *)"cluster_pgsql_replication_hostgroups_save_to_disk",
(char *)"cluster_pgsql_hostgroup_attributes_save_to_disk",
(char *)"cluster_mysql_servers_sync_algorithm",
(char *)"checksum_mysql_query_rules",
(char *)"checksum_mysql_servers",
@ -2669,8 +2665,6 @@ ProxySQL_Admin::ProxySQL_Admin() :
variables.cluster_pgsql_query_rules_diffs_before_sync = 3;
variables.cluster_pgsql_servers_diffs_before_sync = 3;
variables.cluster_pgsql_users_diffs_before_sync = 3;
variables.cluster_pgsql_replication_hostgroups_diffs_before_sync = 3;
variables.cluster_pgsql_hostgroup_attributes_diffs_before_sync = 3;
variables.cluster_mysql_servers_sync_algorithm = 1;
checksum_variables.checksum_mysql_query_rules = true;
checksum_variables.checksum_mysql_servers = true;
@ -2690,8 +2684,6 @@ ProxySQL_Admin::ProxySQL_Admin() :
variables.cluster_pgsql_query_rules_save_to_disk = true;
variables.cluster_pgsql_servers_save_to_disk = true;
variables.cluster_pgsql_users_save_to_disk = true;
variables.cluster_pgsql_replication_hostgroups_save_to_disk = true;
variables.cluster_pgsql_hostgroup_attributes_save_to_disk = true;
variables.stats_mysql_connection_pool = 60;
variables.stats_mysql_connections = 60;
variables.stats_mysql_query_cache = 60;
@ -3427,15 +3419,7 @@ char * ProxySQL_Admin::get_variable(char *name) {
sprintf(intbuf,"%d",variables.cluster_pgsql_users_diffs_before_sync);
return strdup(intbuf);
}
if (!strcasecmp(name,"cluster_pgsql_replication_hostgroups_diffs_before_sync")) {
sprintf(intbuf,"%d",variables.cluster_pgsql_replication_hostgroups_diffs_before_sync);
return strdup(intbuf);
}
if (!strcasecmp(name,"cluster_pgsql_hostgroup_attributes_diffs_before_sync")) {
sprintf(intbuf,"%d",variables.cluster_pgsql_hostgroup_attributes_diffs_before_sync);
return strdup(intbuf);
}
if (!strcasecmp(name,"cluster_pgsql_variables_diffs_before_sync")) {
if (!strcasecmp(name,"cluster_pgsql_variables_diffs_before_sync")) {
sprintf(intbuf,"%d",variables.cluster_pgsql_variables_diffs_before_sync);
return strdup(intbuf);
}
@ -3473,12 +3457,6 @@ char * ProxySQL_Admin::get_variable(char *name) {
if (!strcasecmp(name,"cluster_pgsql_users_save_to_disk")) {
return strdup((variables.cluster_pgsql_users_save_to_disk ? "true" : "false"));
}
if (!strcasecmp(name,"cluster_pgsql_replication_hostgroups_save_to_disk")) {
return strdup((variables.cluster_pgsql_replication_hostgroups_save_to_disk ? "true" : "false"));
}
if (!strcasecmp(name,"cluster_pgsql_hostgroup_attributes_save_to_disk")) {
return strdup((variables.cluster_pgsql_hostgroup_attributes_save_to_disk ? "true" : "false"));
}
if (!strcasecmp(name,"cluster_pgsql_variables_save_to_disk")) {
return strdup((variables.cluster_pgsql_variables_save_to_disk ? "true" : "false"));
}
@ -4038,37 +4016,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
return false;
}
}
if (!strcasecmp(name,"cluster_pgsql_replication_hostgroups_diffs_before_sync")) {
int intv=atoi(value);
if (intv >= 0 && intv <= 1000) {
intv = checksum_variables.checksum_mysql_servers ? intv : 0; // Reuse mysql_servers checksum
if (variables.cluster_pgsql_replication_hostgroups_diffs_before_sync == 0 && intv != 0) {
proxy_info("Re-enabled previously disabled 'admin-cluster_pgsql_replication_hostgroups_diffs_before_sync'. Resetting global checksums to force Cluster re-sync.\n");
GloProxyCluster->Reset_Global_Checksums(lock);
}
variables.cluster_pgsql_replication_hostgroups_diffs_before_sync=intv;
GloProxyCluster->cluster_pgsql_replication_hostgroups_diffs_before_sync = intv;
return true;
} else {
return false;
}
}
if (!strcasecmp(name,"cluster_pgsql_hostgroup_attributes_diffs_before_sync")) {
int intv=atoi(value);
if (intv >= 0 && intv <= 1000) {
intv = checksum_variables.checksum_mysql_servers ? intv : 0; // Reuse mysql_servers checksum
if (variables.cluster_pgsql_hostgroup_attributes_diffs_before_sync == 0 && intv != 0) {
proxy_info("Re-enabled previously disabled 'admin-cluster_pgsql_hostgroup_attributes_diffs_before_sync'. Resetting global checksums to force Cluster re-sync.\n");
GloProxyCluster->Reset_Global_Checksums(lock);
}
variables.cluster_pgsql_hostgroup_attributes_diffs_before_sync=intv;
GloProxyCluster->cluster_pgsql_hostgroup_attributes_diffs_before_sync = intv;
return true;
} else {
return false;
}
}
if (!strcasecmp(name,"cluster_pgsql_variables_diffs_before_sync")) {
if (!strcasecmp(name,"cluster_pgsql_variables_diffs_before_sync")) {
int intv=atoi(value);
if (intv >= 0 && intv <= 1000) {
intv = checksum_variables.checksum_pgsql_variables ? intv : 0;
@ -4324,35 +4272,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
}
return rt;
}
if (!strcasecmp(name,"cluster_pgsql_replication_hostgroups_save_to_disk")) {
bool rt = false;
if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) {
variables.cluster_pgsql_replication_hostgroups_save_to_disk=true;
rt = __sync_lock_test_and_set(&GloProxyCluster->cluster_pgsql_replication_hostgroups_save_to_disk, true);
return true;
}
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
variables.cluster_pgsql_replication_hostgroups_save_to_disk=false;
rt = __sync_lock_test_and_set(&GloProxyCluster->cluster_pgsql_replication_hostgroups_save_to_disk, false);
return true;
}
return rt;
}
if (!strcasecmp(name,"cluster_pgsql_hostgroup_attributes_save_to_disk")) {
bool rt = false;
if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) {
variables.cluster_pgsql_hostgroup_attributes_save_to_disk=true;
rt = __sync_lock_test_and_set(&GloProxyCluster->cluster_pgsql_hostgroup_attributes_save_to_disk, true);
return true;
}
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
variables.cluster_pgsql_hostgroup_attributes_save_to_disk=false;
rt = __sync_lock_test_and_set(&GloProxyCluster->cluster_pgsql_hostgroup_attributes_save_to_disk, false);
return true;
}
return rt;
}
if (!strcasecmp(name,"cluster_pgsql_variables_save_to_disk")) {
if (!strcasecmp(name,"cluster_pgsql_variables_save_to_disk")) {
bool rt = false;
if (strcasecmp(value,"true")==0 || strcasecmp(value,"1")==0) {
variables.cluster_pgsql_variables_save_to_disk=true;
@ -4410,10 +4330,6 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
GloProxyCluster->cluster_mysql_users_diffs_before_sync = 0;
variables.cluster_pgsql_users_diffs_before_sync = 0;
GloProxyCluster->cluster_pgsql_users_diffs_before_sync = 0;
variables.cluster_pgsql_replication_hostgroups_diffs_before_sync = 0;
GloProxyCluster->cluster_pgsql_replication_hostgroups_diffs_before_sync = 0;
variables.cluster_pgsql_hostgroup_attributes_diffs_before_sync = 0;
GloProxyCluster->cluster_pgsql_hostgroup_attributes_diffs_before_sync = 0;
proxy_warning("Disabling deprecated 'admin-checksum_pgsql_users', setting 'admin-cluster_pgsql_users_diffs_before_sync=0'\n");
return true;
}

@ -3106,26 +3106,6 @@ void ProxySQL_Cluster::pull_pgsql_servers_v2_from_peer(const pgsql_servers_v2_ch
"Cluster: Loading to runtime PostgreSQL Servers from peer " + string(hostname) + ":" + std::to_string(port) + ".",
"Cluster: NOT saving to disk PostgreSQL Servers from peer " + string(hostname) + ":" + std::to_string(port) + "."
}
},
{
CLUSTER_QUERY_PGSQL_REPLICATION_HOSTGROUPS,
p_cluster_counter::pulled_pgsql_replication_hostgroups_success,
p_cluster_counter::pulled_pgsql_replication_hostgroups_failure,
{
"Cluster: Fetching PostgreSQL Replication Hostgroups from peer " + string(hostname) + ":" + std::to_string(port) + " completed.",
"Cluster: Loading to runtime PostgreSQL Replication Hostgroups from peer " + string(hostname) + ":" + std::to_string(port) + ".",
"Cluster: NOT saving to disk PostgreSQL Replication Hostgroups from peer " + string(hostname) + ":" + std::to_string(port) + "."
}
},
{
CLUSTER_QUERY_PGSQL_HOSTGROUP_ATTRIBUTES,
p_cluster_counter::pulled_pgsql_hostgroup_attributes_success,
p_cluster_counter::pulled_pgsql_hostgroup_attributes_failure,
{
"Cluster: Fetching PostgreSQL Hostgroup Attributes from peer " + string(hostname) + ":" + std::to_string(port) + " completed.",
"Cluster: Loading to runtime PostgreSQL Hostgroup Attributes from peer " + string(hostname) + ":" + std::to_string(port) + ".",
"Cluster: NOT saving to disk PostgreSQL Hostgroup Attributes from peer " + string(hostname) + ":" + std::to_string(port) + "."
}
}
};
@ -3621,11 +3601,7 @@ void ProxySQL_Cluster_Nodes::get_peer_to_sync_variables_module(const char* modul
{"ldap_variables", &ProxySQL_Cluster::cluster_ldap_variables_diffs_before_sync,
[](ProxySQL_Node_Entry* node) { return &node->checksums_values.ldap_variables; }, nullptr, false, false, nullptr},
{"pgsql_variables", &ProxySQL_Cluster::cluster_pgsql_variables_diffs_before_sync,
[](ProxySQL_Node_Entry* node) { return &node->checksums_values.pgsql_variables; }, nullptr, false, false, nullptr},
{"pgsql_replication_hostgroups", &ProxySQL_Cluster::cluster_pgsql_replication_hostgroups_diffs_before_sync,
[](ProxySQL_Node_Entry* node) { return &node->checksums_values.pgsql_servers; }, nullptr, false, false, nullptr},
{"pgsql_hostgroup_attributes", &ProxySQL_Cluster::cluster_pgsql_hostgroup_attributes_diffs_before_sync,
[](ProxySQL_Node_Entry* node) { return &node->checksums_values.pgsql_servers; }, nullptr, false, false, nullptr}
[](ProxySQL_Node_Entry* node) { return &node->checksums_values.pgsql_variables; }, nullptr, false, false, nullptr}
};
// Find the matching module configuration
@ -4852,87 +4828,6 @@ cluster_metrics_map = std::make_tuple(
{ "reason", "version_one" }
}
),
// ====================================================================
// pgsql_replication_hostgroups
// ====================================================================
std::make_tuple (
p_cluster_counter::pulled_pgsql_replication_hostgroups_success,
"proxysql_cluster_pulled_total",
"Number of times a 'module' have been pulled from a peer.",
metric_tags {
{ "module_name", "pgsql_replication_hostgroups" },
{ "status", "success" }
}
),
std::make_tuple (
p_cluster_counter::pulled_pgsql_replication_hostgroups_failure,
"proxysql_cluster_pulled_total",
"Number of times a 'module' have been pulled from a peer.",
metric_tags {
{ "module_name", "pgsql_replication_hostgroups" },
{ "status", "failure" }
}
),
std::make_tuple (
p_cluster_counter::sync_conflict_pgsql_replication_hostgroups_share_epoch,
"proxysql_cluster_sync_conflict_total",
"Number of times a 'module' has not been able to be synced.",
metric_tags {
{ "module_name", "pgsql_replication_hostgroups" },
{ "reason", "share_epoch" }
}
),
std::make_tuple (
p_cluster_counter::sync_delayed_pgsql_replication_hostgroups_version_one,
"proxysql_cluster_syn_conflict_total",
"Number of times a 'module' has not been able to be synced.",
metric_tags {
{ "module_name", "pgsql_replication_hostgroups" },
{ "reason", "version_one" }
}
),
// ====================================================================
// pgsql_hostgroup_attributes
// ====================================================================
std::make_tuple (
p_cluster_counter::pulled_pgsql_hostgroup_attributes_success,
"proxysql_cluster_pulled_total",
"Number of times a 'module' have been pulled from a peer.",
metric_tags {
{ "module_name", "pgsql_hostgroup_attributes" },
{ "status", "success" }
}
),
std::make_tuple (
p_cluster_counter::pulled_pgsql_hostgroup_attributes_failure,
"proxysql_cluster_pulled_total",
"Number of times a 'module' have been pulled from a peer.",
metric_tags {
{ "module_name", "pgsql_hostgroup_attributes" },
{ "status", "failure" }
}
),
std::make_tuple (
p_cluster_counter::sync_conflict_pgsql_hostgroup_attributes_share_epoch,
"proxysql_cluster_sync_conflict_total",
"Number of times a 'module' has not been able to be synced.",
metric_tags {
{ "module_name", "pgsql_hostgroup_attributes" },
{ "reason", "share_epoch" }
}
),
std::make_tuple (
p_cluster_counter::sync_delayed_pgsql_hostgroup_attributes_version_one,
"proxysql_cluster_syn_conflict_total",
"Number of times a 'module' has not been able to be synced.",
metric_tags {
{ "module_name", "pgsql_hostgroup_attributes" },
{ "reason", "version_one" }
}
),
// ====================================================================
},
cluster_gauge_vector {}
);
@ -4962,14 +4857,10 @@ ProxySQL_Cluster::ProxySQL_Cluster() : proxysql_servers_to_monitor(NULL) {
cluster_pgsql_servers_diffs_before_sync = 3;
cluster_pgsql_users_diffs_before_sync = 3;
cluster_pgsql_variables_diffs_before_sync = 3;
cluster_pgsql_replication_hostgroups_diffs_before_sync = 3;
cluster_pgsql_hostgroup_attributes_diffs_before_sync = 3;
cluster_mysql_query_rules_save_to_disk = true;
cluster_mysql_servers_save_to_disk = true;
cluster_mysql_users_save_to_disk = true;
cluster_proxysql_servers_save_to_disk = true;
cluster_pgsql_replication_hostgroups_save_to_disk = true;
cluster_pgsql_hostgroup_attributes_save_to_disk = true;
cluster_mysql_servers_sync_algorithm = 1;
init_prometheus_counter_array<cluster_metrics_map_idx, p_cluster_counter>(cluster_metrics_map, this->metrics.p_counter_array);
init_prometheus_gauge_array<cluster_metrics_map_idx, p_cluster_gauge>(cluster_metrics_map, this->metrics.p_gauge_array);

Loading…
Cancel
Save