Skip to content

Commit

Permalink
Fix interactions between 'checksum_%' and '%_diffs_before_sync'
Browse files Browse the repository at this point in the history
- Introduced dependency between 'checksum_variables' and their
  corresponding '%_diffs_before_sync' variable. Checksum variables being
  'false' implies a '0' value. Variable dependencies need to be
  introduced in the handler for both variables, since order can't be
  assumed.
- Added missing sets statements for 'GloProxyCluster' variables when
  updating '%_diffs_before_sync'.
- Fixed typo in 'cluster_ldap_variables_diffs_before_sync' handling,
  creating unintentional checksum resets.
  • Loading branch information
JavierJF committed Nov 13, 2023
1 parent 2d0c8bf commit 437fcad
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/ProxySQL_Admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8390,6 +8390,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (!strcasecmp(name,"cluster_mysql_query_rules_diffs_before_sync")) {
int intv=atoi(value);
if (intv >= 0 && intv <= 1000) {
intv = checksum_variables.checksum_mysql_query_rules ? intv : 0;
if (variables.cluster_mysql_query_rules_diffs_before_sync == 0 && intv != 0) {
proxy_info("Re-enabled previously disabled 'admin-cluster_admin_variables_diffs_before_sync'. Resetting global checksums to force Cluster re-sync.\n");
GloProxyCluster->Reset_Global_Checksums(lock);
Expand All @@ -8404,6 +8405,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (!strcasecmp(name,"cluster_mysql_servers_diffs_before_sync")) {
int intv=atoi(value);
if (intv >= 0 && intv <= 1000) {
intv = checksum_variables.checksum_mysql_servers ? intv : 0;
if (variables.cluster_mysql_servers_diffs_before_sync == 0 && intv != 0) {
proxy_info("Re-enabled previously disabled 'admin-cluster_mysql_servers_diffs_before_sync'. Resetting global checksums to force Cluster re-sync.\n");
GloProxyCluster->Reset_Global_Checksums(lock);
Expand All @@ -8418,6 +8420,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (!strcasecmp(name,"cluster_mysql_users_diffs_before_sync")) {
int intv=atoi(value);
if (intv >= 0 && intv <= 1000) {
intv = checksum_variables.checksum_mysql_users ? intv : 0;
if (variables.cluster_mysql_users_diffs_before_sync == 0 && intv != 0) {
proxy_info("Re-enabled previously disabled 'admin-cluster_mysql_users_diffs_before_sync'. Resetting global checksums to force Cluster re-sync.\n");
GloProxyCluster->Reset_Global_Checksums(lock);
Expand Down Expand Up @@ -8446,6 +8449,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (!strcasecmp(name,"cluster_mysql_variables_diffs_before_sync")) {
int intv=atoi(value);
if (intv >= 0 && intv <= 1000) {
intv = checksum_variables.checksum_mysql_variables ? intv : 0;
if (variables.cluster_mysql_variables_diffs_before_sync == 0 && intv != 0) {
proxy_info("Re-enabled previously disabled 'admin-cluster_mysql_variables_diffs_before_sync'. Resetting global checksums to force Cluster re-sync.\n");
GloProxyCluster->Reset_Global_Checksums(lock);
Expand All @@ -8460,6 +8464,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (!strcasecmp(name,"cluster_admin_variables_diffs_before_sync")) {
int intv=atoi(value);
if (intv >= 0 && intv <= 1000) {
intv = checksum_variables.checksum_admin_variables ? intv : 0;
if (variables.cluster_admin_variables_diffs_before_sync == 0 && intv != 0) {
proxy_info("Re-enabled previously disabled 'admin-cluster_admin_variables_diffs_before_sync'. Resetting global checksums to force Cluster re-sync.\n");
GloProxyCluster->Reset_Global_Checksums(lock);
Expand All @@ -8474,7 +8479,8 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (!strcasecmp(name,"cluster_ldap_variables_diffs_before_sync")) {
int intv=atoi(value);
if (intv >= 0 && intv <= 1000) {
if (variables.cluster_ldap_variables_save_to_disk == 0 && intv != 0) {
intv = checksum_variables.checksum_ldap_variables ? intv : 0;
if (variables.cluster_ldap_variables_diffs_before_sync == 0 && intv != 0) {
proxy_info("Re-enabled previously disabled 'admin-cluster_ldap_variables_diffs_before_sync'. Resetting global checksums to force Cluster re-sync.\n");
GloProxyCluster->Reset_Global_Checksums(lock);
}
Expand Down Expand Up @@ -8673,6 +8679,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
checksum_variables.checksum_mysql_query_rules=false;
variables.cluster_mysql_query_rules_diffs_before_sync = 0;
__sync_lock_test_and_set(&GloProxyCluster->cluster_mysql_query_rules_diffs_before_sync, 0);
proxy_warning("Disabling deprecated 'admin-checksum_mysql_query_rules', setting 'admin-cluster_mysql_query_rules_diffs_before_sync=0'\n");
return true;
}
Expand All @@ -8686,6 +8693,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
checksum_variables.checksum_mysql_servers=false;
variables.cluster_mysql_servers_diffs_before_sync = 0;
__sync_lock_test_and_set(&GloProxyCluster->cluster_mysql_servers_diffs_before_sync, 0);
proxy_warning("Disabling deprecated 'admin-checksum_mysql_servers', setting 'admin-cluster_mysql_servers_diffs_before_sync=0'\n");
return true;
}
Expand All @@ -8700,6 +8708,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
checksum_variables.checksum_mysql_users=false;
variables.cluster_mysql_users_diffs_before_sync = 0;
__sync_lock_test_and_set(&GloProxyCluster->cluster_mysql_users_diffs_before_sync, 0);
proxy_warning("Disabling deprecated 'admin-checksum_mysql_users', setting 'admin-cluster_mysql_users_diffs_before_sync=0'\n");
return true;
}
Expand All @@ -8713,6 +8722,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
checksum_variables.checksum_mysql_variables=false;
variables.cluster_mysql_variables_diffs_before_sync = 0;
__sync_lock_test_and_set(&GloProxyCluster->cluster_mysql_variables_diffs_before_sync, 0);
proxy_warning("Disabling deprecated 'admin-checksum_mysql_variables', setting 'admin-cluster_mysql_variables_diffs_before_sync=0'\n");
return true;
}
Expand All @@ -8726,6 +8736,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
checksum_variables.checksum_admin_variables=false;
variables.cluster_admin_variables_diffs_before_sync = 0;
__sync_lock_test_and_set(&GloProxyCluster->cluster_admin_variables_diffs_before_sync, 0);
proxy_warning("Disabling deprecated 'admin-checksum_admin_variables', setting 'admin-cluster_admin_variables_diffs_before_sync=0'\n");
return true;
}
Expand All @@ -8739,6 +8750,7 @@ bool ProxySQL_Admin::set_variable(char *name, char *value, bool lock) { // this
if (strcasecmp(value,"false")==0 || strcasecmp(value,"0")==0) {
checksum_variables.checksum_ldap_variables=false;
variables.cluster_ldap_variables_diffs_before_sync = 0;
__sync_lock_test_and_set(&GloProxyCluster->cluster_ldap_variables_diffs_before_sync, 0);
proxy_warning("Disabling deprecated 'admin-checksum_ldap_variables', setting 'admin-cluster_ldap_variables_diffs_before_sync=0'\n");
return true;
}
Expand Down

0 comments on commit 437fcad

Please sign in to comment.