From a35e790a4d9236893dbe3f12eaa540b03dfb2287 Mon Sep 17 00:00:00 2001 From: digimer Date: Fri, 20 Oct 2023 11:38:15 -0400 Subject: [PATCH 01/10] Fixed a minor striker-boot-machine bug. Divide by zero error when no hosts with IPMI found. Signed-off-by: digimer --- share/words.xml | 1 + tools/striker-boot-machine | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/share/words.xml b/share/words.xml index 0ee0c687..53065f33 100644 --- a/share/words.xml +++ b/share/words.xml @@ -3179,6 +3179,7 @@ Proceed? [y/N] This host is now configured to map the network. This host is already NOT configured to map the network. This host is no longer configured to map the network. + No hosts with IPMI found, done. Normal Password diff --git a/tools/striker-boot-machine b/tools/striker-boot-machine index 8a99e5ff..1c023f51 100755 --- a/tools/striker-boot-machine +++ b/tools/striker-boot-machine @@ -151,11 +151,16 @@ sub find_boot_method } my $host_count = @{$hosts}; - my $steps = int((80 / $host_count) / 3); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { - host_count => $host_count, - steps => $steps, - }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_count => $host_count }}); + if (not $host_count) + { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "message_0357"}); + $anvil->Job->update_progress({progress => 100, message => "message_0357"}); + $anvil->nice_exit({exit_code => 0}); + } + + my $steps = int((80 / $host_count) / 3); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { steps => $steps }}); $anvil->data->{sys}{progress} = 5; foreach my $host_name (sort {$a cmp $b} @{$hosts}) From a11b87458e21ad1478e7349982207735e6d93839 Mon Sep 17 00:00:00 2001 From: digimer Date: Fri, 20 Oct 2023 19:15:04 -0400 Subject: [PATCH 02/10] Gracefully handle errors from changed node host names in scan-cluster. Signed-off-by: digimer --- scancore-agents/scan-cluster/scan-cluster | 19 ++++++++++++++----- scancore-agents/scan-cluster/scan-cluster.xml | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/scancore-agents/scan-cluster/scan-cluster b/scancore-agents/scan-cluster/scan-cluster index dac1623c..a074d669 100755 --- a/scancore-agents/scan-cluster/scan-cluster +++ b/scancore-agents/scan-cluster/scan-cluster @@ -418,7 +418,7 @@ sub check_if_server_failed my ($anvil, $server) = @_; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { server => $server }}); - $anvil->Cluster->parse_crm_mon({debug => 3}); + $anvil->Cluster->parse_crm_mon({debug => 2}); my $failed = exists $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{resource}{$server}{variables}{failed} ? $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{resource}{$server}{variables}{failed} : 0; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { failed => $failed }}); if ($failed eq "true") @@ -708,15 +708,24 @@ INSERT INTO $anvil->Database->get_anvils(); foreach my $scan_cluster_node_name (sort {$a cmp $b} keys %{$anvil->data->{cib}{parsed}{data}{node}}) { - my $scan_cluster_node_host_uuid = $anvil->Get->host_uuid_from_name({host_name => $scan_cluster_node_name}); + my $scan_cluster_node_host_uuid = $anvil->Get->host_uuid_from_name({host_name => $scan_cluster_node_name}) // ""; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + scan_cluster_node_name => $scan_cluster_node_name, + scan_cluster_node_host_uuid => $scan_cluster_node_host_uuid, + }}); + if (not $scan_cluster_node_host_uuid) + { + # Something is wrong with this host. Does the hostname match to node name? + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_cluster_alert_0016", variables => { node_name => $scan_cluster_node_name }}); + next; + } + my $scan_cluster_node_pacemaker_id = $anvil->data->{cib}{parsed}{data}{node}{$scan_cluster_node_name}{node_state}{pacemaker_id}; my $scan_cluster_node_in_ccm = $anvil->data->{cib}{parsed}{data}{node}{$scan_cluster_node_name}{node_state}{in_ccm}; my $scan_cluster_node_crmd_member = $anvil->data->{cib}{parsed}{data}{node}{$scan_cluster_node_name}{node_state}{crmd}; my $scan_cluster_node_cluster_member = $anvil->data->{cib}{parsed}{data}{node}{$scan_cluster_node_name}{node_state}{'join'}; my $scan_cluster_node_maintenance_mode = $anvil->data->{cib}{parsed}{data}{node}{$scan_cluster_node_name}{node_state}{'maintenance-mode'}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { - scan_cluster_node_name => $scan_cluster_node_name, - scan_cluster_node_host_uuid => $scan_cluster_node_host_uuid, scan_cluster_node_pacemaker_id => $scan_cluster_node_pacemaker_id, scan_cluster_node_in_ccm => $scan_cluster_node_in_ccm, scan_cluster_node_crmd_member => $scan_cluster_node_crmd_member, @@ -1044,7 +1053,7 @@ sub collect_data my ($anvil) = @_; # Pick out core cluster details. - my $problem = $anvil->Cluster->parse_cib({debug => 3}); + my $problem = $anvil->Cluster->parse_cib({debug => 2}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { problem => $problem }}); # If there was a problem, we're not in the cluster. diff --git a/scancore-agents/scan-cluster/scan-cluster.xml b/scancore-agents/scan-cluster/scan-cluster.xml index ba2b7869..218df643 100644 --- a/scancore-agents/scan-cluster/scan-cluster.xml +++ b/scancore-agents/scan-cluster/scan-cluster.xml @@ -40,6 +40,7 @@ In Maintenance Mode: ..... [#!variable!maintenance_mode!#] The server: [#!variable!server!#] was found to be failed in pacemaker, but it was successfully recovered. This does NOT mean the server rebooted, but it may have. Checking the server is advised. The server: [#!variable!server!#] was found to be failed in pacemaker. The attempt to recover it appears to have failed. The server might well still be running ok, checking the server is advised. The server: [#!variable!server!#] had been found to be failed in pacemaker. It's now recovered. This does NOT mean the server rebooted, but it may have. Checking the server is advised. + The node name: [#!variable!node_name!#] failed to translate to a host UUID. Does the node name match the host name? Starting: [#!variable!program!#]. From ed269aa450990177427c6ef2a52352651bdce972 Mon Sep 17 00:00:00 2001 From: digimer Date: Fri, 20 Oct 2023 22:05:33 -0400 Subject: [PATCH 03/10] Fixed a bug where duplicate variables were being created in some cases. Signed-off-by: digimer --- Anvil/Tools/Database.pm | 73 +++++++++++++++++++++++++++++++++++++++++ share/words.xml | 1 + 2 files changed, 74 insertions(+) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 34830a0d..1ea2df19 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -18150,6 +18150,79 @@ sub resync_databases # We're done with the table data, clear it. delete $anvil->data->{sys}{database}{table}; + # Look for duplicate entries in variables. This is done here as it's too generic to tag elsewhere + if (1) + { + my $query = " +SELECT + variable_uuid, + variable_section, + variable_name, + variable_source_table, + variable_source_uuid, + variable_value, + modified_date +FROM + variables +ORDER BY + modified_date DESC; +;"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); + + my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); + my $count = @{$results}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + results => $results, + count => $count, + }}); + foreach my $row (@{$results}) + { + my $variable_uuid = $row->[0]; + my $variable_section = $row->[1]; + my $variable_name = $row->[2]; + my $variable_source_table = $row->[3]; + my $variable_source_uuid = $row->[4] // "none"; + my $variable_value = $row->[5]; + my $modified_date = $row->[6]; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + variable_uuid => $variable_uuid, + variable_section => $variable_section, + variable_name => $variable_name, + variable_source_table => $variable_source_table, + variable_source_uuid => $variable_source_uuid, + variable_value => $variable_value, + modified_date => $modified_date, + }}); + + if (not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}) + { + # Save it. + $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value} = $variable_value; + $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid} = $variable_uuid; + } + else + { + # Duplicate! This is older, so delete it. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "warning_0165", variables => { + section => $variable_section, + name => $variable_name, + source_table => $variable_source_table, + source_uuid => $variable_source_uuid, + value => $variable_value, + }}); + + my $queries = []; + push @{$queries}, "DELETE FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid).";"; + push @{$queries}, "DELETE FROM variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid).";"; + foreach my $query (@{$queries}) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); + } + $anvil->Database->write({query => $queries, source => $THIS_FILE, line => __LINE__}); + } + } + } + # Clear the variable that indicates we need a resync. $anvil->data->{sys}{database}{resync_needed} = 0; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'sys::database::resync_needed' => $anvil->data->{sys}{database}{resync_needed} }}); diff --git a/share/words.xml b/share/words.xml index 53065f33..589bd522 100644 --- a/share/words.xml +++ b/share/words.xml @@ -3953,6 +3953,7 @@ We will try to proceed anyway. + From 1824bb2eedb83d143b0e8906bf0b98ef333efcfd Mon Sep 17 00:00:00 2001 From: digimer Date: Fri, 20 Oct 2023 23:41:21 -0400 Subject: [PATCH 04/10] Added forced DB resyncs to striker-manage-peers Signed-off-by: digimer --- tools/striker-manage-peers | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/striker-manage-peers b/tools/striker-manage-peers index dd7b81bc..58dae0af 100755 --- a/tools/striker-manage-peers +++ b/tools/striker-manage-peers @@ -60,7 +60,11 @@ if (($< != 0) && ($> != 0)) } # We'll try to connect in case we're adding additional peers. -$anvil->Database->connect(); +$anvil->data->{sys}{database}{resync_needed} = 1; +$anvil->Database->connect({ + debug => 2, + check_for_resync => 1, +}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); # Am I adding, editing or deleting? @@ -537,7 +541,8 @@ sub process_entry # Re-read the config. $anvil->refresh(); - # Connect, and configure, if needed. + # Flag a resync, connect, and configure, if needed. + $anvil->data->{sys}{database}{resync_needed} = 1; $anvil->Database->connect({ debug => 3, check_for_resync => 1, @@ -621,7 +626,12 @@ sub process_entry sleep 1; - $anvil->Database->connect({check_for_resync => 1, db_uuid => $host_uuid}); + $anvil->data->{sys}{database}{resync_needed} = 1; + $anvil->Database->connect({ + debug => 2, + check_for_resync => 1, + db_uuid => $host_uuid, + }); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); } } From 2a3f0bab2429a37b41f3a72e3bbffad1281a4bf6 Mon Sep 17 00:00:00 2001 From: digimer Date: Sat, 21 Oct 2023 13:33:14 -0400 Subject: [PATCH 05/10] Reworked how and when duplicate variables are checked/cleared. Moved the logic to a new private method, and call it now from the active Striker in the once per minute loop. The duplicate variable issue seems to be not entirely uncommon. Signed-off-by: digimer --- Anvil/Tools/Database.pm | 161 ++++++++++++++++++++++------------------ tools/anvil-daemon | 6 ++ 2 files changed, 94 insertions(+), 73 deletions(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 1ea2df19..1db12b3a 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -105,6 +105,7 @@ my $THIS_FILE = "Database.pm"; # _add_to_local_config # _age_out_data # _archive_table +# _check_for_duplicates # _find_column # _find_behind_database # _mark_database_as_behind @@ -18150,79 +18151,6 @@ sub resync_databases # We're done with the table data, clear it. delete $anvil->data->{sys}{database}{table}; - # Look for duplicate entries in variables. This is done here as it's too generic to tag elsewhere - if (1) - { - my $query = " -SELECT - variable_uuid, - variable_section, - variable_name, - variable_source_table, - variable_source_uuid, - variable_value, - modified_date -FROM - variables -ORDER BY - modified_date DESC; -;"; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); - - my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); - my $count = @{$results}; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - results => $results, - count => $count, - }}); - foreach my $row (@{$results}) - { - my $variable_uuid = $row->[0]; - my $variable_section = $row->[1]; - my $variable_name = $row->[2]; - my $variable_source_table = $row->[3]; - my $variable_source_uuid = $row->[4] // "none"; - my $variable_value = $row->[5]; - my $modified_date = $row->[6]; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - variable_uuid => $variable_uuid, - variable_section => $variable_section, - variable_name => $variable_name, - variable_source_table => $variable_source_table, - variable_source_uuid => $variable_source_uuid, - variable_value => $variable_value, - modified_date => $modified_date, - }}); - - if (not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}) - { - # Save it. - $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value} = $variable_value; - $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid} = $variable_uuid; - } - else - { - # Duplicate! This is older, so delete it. - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "warning_0165", variables => { - section => $variable_section, - name => $variable_name, - source_table => $variable_source_table, - source_uuid => $variable_source_uuid, - value => $variable_value, - }}); - - my $queries = []; - push @{$queries}, "DELETE FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid).";"; - push @{$queries}, "DELETE FROM variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid).";"; - foreach my $query (@{$queries}) - { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); - } - $anvil->Database->write({query => $queries, source => $THIS_FILE, line => __LINE__}); - } - } - } - # Clear the variable that indicates we need a resync. $anvil->data->{sys}{database}{resync_needed} = 0; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'sys::database::resync_needed' => $anvil->data->{sys}{database}{resync_needed} }}); @@ -19722,6 +19650,93 @@ COPY history.".$table." ("; } +=head2 _check_for_duplicates + +This method looks for duplicate entries in the database and clears them, if found. + +This method takes no parameters + +=cut +sub _check_for_duplicates +{ + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->_check_for_duplicates()" }}); + + my $query = " +SELECT + variable_uuid, + variable_section, + variable_name, + variable_source_table, + variable_source_uuid, + variable_value, + modified_date +FROM + variables +ORDER BY + modified_date DESC; +;"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); + + my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); + my $count = @{$results}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + results => $results, + count => $count, + }}); + foreach my $row (@{$results}) + { + my $variable_uuid = $row->[0]; + my $variable_section = $row->[1]; + my $variable_name = $row->[2]; + my $variable_source_table = $row->[3] // "none"; + my $variable_source_uuid = $row->[4] // "none"; + my $variable_value = $row->[5]; + my $modified_date = $row->[6]; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + variable_uuid => $variable_uuid, + variable_section => $variable_section, + variable_name => $variable_name, + variable_source_table => $variable_source_table, + variable_source_uuid => $variable_source_uuid, + variable_value => $variable_value, + modified_date => $modified_date, + }}); + + if (not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}) + { + # Save it. + $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value} = $variable_value; + $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid} = $variable_uuid; + } + else + { + # Duplicate! This is older, so delete it. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "warning_0165", variables => { + section => $variable_section, + name => $variable_name, + source_table => $variable_source_table, + source_uuid => $variable_source_uuid, + value => $variable_value, + }}); + + my $queries = []; + push @{$queries}, "DELETE FROM history.variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid).";"; + push @{$queries}, "DELETE FROM variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid).";"; + foreach my $query (@{$queries}) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); + } + $anvil->Database->write({query => $queries, source => $THIS_FILE, line => __LINE__}); + } + } + + return(0); +} + =head2 _find_column This takes a table name and looks for a column that ends in C<< _host_uuid >> and, if found, stores it in the C<< sys::database::uuid_tables >> array. diff --git a/tools/anvil-daemon b/tools/anvil-daemon index e2963538..ef59e072 100755 --- a/tools/anvil-daemon +++ b/tools/anvil-daemon @@ -593,6 +593,12 @@ sub handle_periodic_tasks output => $output, return_code => $return_code, }}); + + # Look for duplicates if we're the primary DB. + if ($anvil->Get->host_uuid eq $anvil->data->{sys}{database}{primary_db}) + { + $anvil->Database->_check_for_duplicates({debug => 2}); + } } } From 9ee8f782eed7fb42d45b826ce7fce43d0c90be89 Mon Sep 17 00:00:00 2001 From: digimer Date: Sat, 21 Oct 2023 14:31:14 -0400 Subject: [PATCH 06/10] Continuing to try to resolve duplicate variables bug. * Added a called to Database->_check_for_duplicates to Database->resync_databases * Added 'check_for_resync => 1' to anvil-configure-host. Signed-off-by: digimer --- Anvil/Tools/Database.pm | 5 ++++- tools/anvil-configure-host | 2 +- tools/anvil-daemon | 16 ++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 1db12b3a..b57200bd 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -18151,6 +18151,9 @@ sub resync_databases # We're done with the table data, clear it. delete $anvil->data->{sys}{database}{table}; + # Search for duplicates from the resync + $anvil->Database->_check_for_duplicates({debug => 2}); + # Clear the variable that indicates we need a resync. $anvil->data->{sys}{database}{resync_needed} = 0; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'sys::database::resync_needed' => $anvil->data->{sys}{database}{resync_needed} }}); @@ -19728,7 +19731,7 @@ ORDER BY push @{$queries}, "DELETE FROM variables WHERE variable_uuid = ".$anvil->Database->quote($variable_uuid).";"; foreach my $query (@{$queries}) { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { query => $query }}); } $anvil->Database->write({query => $queries, source => $THIS_FILE, line => __LINE__}); } diff --git a/tools/anvil-configure-host b/tools/anvil-configure-host index 381369c7..adc32550 100755 --- a/tools/anvil-configure-host +++ b/tools/anvil-configure-host @@ -50,7 +50,7 @@ if (($< != 0) && ($> != 0)) } # Connect -$anvil->Database->connect(); +$anvil->Database->connect({debug => 2, check_for_resync => 1}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "message_0031"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print' => 1, key => "log_0132"}); if (not $anvil->data->{sys}{database}{connections}) diff --git a/tools/anvil-daemon b/tools/anvil-daemon index ef59e072..ddf28133 100755 --- a/tools/anvil-daemon +++ b/tools/anvil-daemon @@ -580,6 +580,16 @@ sub handle_periodic_tasks $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_type => $host_type }}); if ($host_type eq "striker") { + # Look for duplicates if we're the primary DB. + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "sys::database::primary_db" => $anvil->data->{sys}{database}{primary_db}, + "Get->host_uuid" => $anvil->Get->host_uuid, + }}); + if ($anvil->Get->host_uuid eq $anvil->data->{sys}{database}{primary_db}) + { + $anvil->Database->_check_for_duplicates({debug => 2}); + } + # This can take a while, but it's been optimized to minimize how long it takes to # run. To be safe, we'll still background it. my $shell_call = $anvil->data->{path}{exe}{'striker-get-screenshots'}.$anvil->Log->switches; @@ -593,12 +603,6 @@ sub handle_periodic_tasks output => $output, return_code => $return_code, }}); - - # Look for duplicates if we're the primary DB. - if ($anvil->Get->host_uuid eq $anvil->data->{sys}{database}{primary_db}) - { - $anvil->Database->_check_for_duplicates({debug => 2}); - } } } From 4d1528f6144affe81f0c63564c8e4df7986192cc Mon Sep 17 00:00:00 2001 From: digimer Date: Sat, 21 Oct 2023 23:10:31 -0400 Subject: [PATCH 07/10] Added more logging to debug variable deletion bug. Signed-off-by: digimer --- Anvil/Tools/Database.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index b57200bd..2b6a0ed4 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -19709,7 +19709,8 @@ ORDER BY modified_date => $modified_date, }}); - if (not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}) + if ((not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}) && + (not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid})) { # Save it. $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value} = $variable_value; @@ -19718,6 +19719,11 @@ ORDER BY else { # Duplicate! This is older, so delete it. + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { + "duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_value" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value}, + "duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_uuid" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid}, + }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "warning_0165", variables => { section => $variable_section, name => $variable_name, From 56bb18951aa3e032fdb3d33db57a4c2c6f181c46 Mon Sep 17 00:00:00 2001 From: digimer Date: Sun, 22 Oct 2023 00:11:24 -0400 Subject: [PATCH 08/10] Hopefully fixed an empty variable bug in duplicate variable searches. Signed-off-by: digimer --- Anvil/Tools/Database.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 2b6a0ed4..0706f6f1 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -19695,8 +19695,8 @@ ORDER BY my $variable_uuid = $row->[0]; my $variable_section = $row->[1]; my $variable_name = $row->[2]; - my $variable_source_table = $row->[3] // "none"; - my $variable_source_uuid = $row->[4] // "none"; + my $variable_source_table = $row->[3] ? $row->[3] : "none"; + my $variable_source_uuid = $row->[4] ? $row->[4] : "none"; my $variable_value = $row->[5]; my $modified_date = $row->[6]; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { @@ -19709,6 +19709,17 @@ ORDER BY modified_date => $modified_date, }}); + if (not $variable_source_table) + { + $variable_source_table = "none"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { variable_source_table => $variable_source_table }}); + } + if (not $variable_source_uuid) + { + $variable_source_uuid = "none"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { variable_source_uuid => $variable_source_uuid }}); + } + if ((not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}) && (not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid})) { From 8bc35b322f7e027e845cd75e55022c1f9617e152 Mon Sep 17 00:00:00 2001 From: digimer Date: Mon, 23 Oct 2023 00:24:23 -0400 Subject: [PATCH 09/10] More logging to debug variable deletion bug. Signed-off-by: digimer --- Anvil/Tools/Database.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 0706f6f1..a7a623f8 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -19699,7 +19699,7 @@ ORDER BY my $variable_source_uuid = $row->[4] ? $row->[4] : "none"; my $variable_value = $row->[5]; my $modified_date = $row->[6]; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { variable_uuid => $variable_uuid, variable_section => $variable_section, variable_name => $variable_name, @@ -19726,6 +19726,10 @@ ORDER BY # Save it. $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value} = $variable_value; $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid} = $variable_uuid; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { + "duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_value" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value}, + "duplicate_variables::${variable_section}::${variable_name}::${variable_source_table}::${variable_source_uuid}::variable_uuid" => $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid}, + }}); } else { From a5f424d340577e0cea587eab9cc2c7aafd5766d3 Mon Sep 17 00:00:00 2001 From: digimer Date: Mon, 23 Oct 2023 12:58:15 -0400 Subject: [PATCH 10/10] Test fix for variable deletion bug. Signed-off-by: digimer --- Anvil/Tools/Database.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index a7a623f8..62625b41 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -19721,7 +19721,7 @@ ORDER BY } if ((not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}) && - (not exists $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid})) + (not $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_uuid})) { # Save it. $anvil->data->{duplicate_variables}{$variable_section}{$variable_name}{$variable_source_table}{$variable_source_uuid}{variable_value} = $variable_value; @@ -19758,6 +19758,9 @@ ORDER BY } } + # Delete to hash. + delete $anvil->data->{duplicate_variables}; + return(0); }