From 9ee8f782eed7fb42d45b826ce7fce43d0c90be89 Mon Sep 17 00:00:00 2001 From: digimer Date: Sat, 21 Oct 2023 14:31:14 -0400 Subject: [PATCH] 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}); - } } }