@ -590,6 +590,9 @@ sub handle_periodic_tasks
$anvil->Database->_check_for_duplicates({debug => 2});
$anvil->Database->_check_for_duplicates({debug => 2});
}
}
# Something is causing broken manifests to be created. Until found, this removes them.
check_for_broken_manifests($anvil);
# This can take a while, but it's been optimized to minimize how long it takes to
# 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.
# run. To be safe, we'll still background it.
my $shell_call = $anvil->data->{path}{exe}{'striker-get-screenshots'}.$anvil->Log->switches;
my $shell_call = $anvil->data->{path}{exe}{'striker-get-screenshots'}.$anvil->Log->switches;
@ -880,6 +883,47 @@ sub handle_periodic_tasks
return(0);
return(0);
}
}
### TODO: Find the source of the problem and fix it properly.
sub check_for_broken_manifests
{
my ($anvil) = @_;
my $query = "
SELECT
manifest_uuid
FROM
manifests
WHERE
manifest_name = '-anvil-'
;";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0124", variables => { 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 => 2, list => {
results => $results,
count => $count,
}});
if ($count)
{
foreach my $row (@{$results})
{
my $manifest_uuid = $row->[0];
my $queries = [];
push @{$queries}, "DELETE FROM history.manifests WHERE manifest_uuid = ".$anvil->Database->quote($manifest_uuid).";";
push @{$queries}, "DELETE FROM manifests WHERE manifest_uuid = ".$anvil->Database->quote($manifest_uuid).";";
foreach my $query (sort {$a cmp $b} @{$queries})
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0124", variables => { query => $query }});
}
$anvil->Database->write({debug => 2, query => $queries, source => $THIS_FILE, line => __LINE__});
}
}
return(0);
}
### NOTE: This logic plays out in a slightly different way in Database->shutdown().
### NOTE: This logic plays out in a slightly different way in Database->shutdown().
# Check for stale db_in_use states.
# Check for stale db_in_use states.
sub check_db_in_use_states
sub check_db_in_use_states