* Updated Database->insert_or_update_states() to not actually record unless the state_host_uuid exists in all available databases.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent 7b090e1623
commit 422d248cbe
  1. 42
      Anvil/Tools/Database.pm
  2. 1
      share/words.xml

@ -12226,6 +12226,48 @@ sub insert_or_update_states
return(""); return("");
} }
# It's possible during initialization that a state could be set before the host is in the database's
# hosts table. This prevents that condition from causing a problem.
my $hosts_ok = 1;
my $db_uuids = [];
my $query = "SELECT COUNT(*) FROM hosts WHERE host_uuid = ".$anvil->Database->quote($state_host_uuid).";";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
if ($uuid)
{
push @{$db_uuids}, $uuid;
}
else
{
foreach my $db_uuid (sort {$a cmp $b} keys %{$anvil->data->{cache}{database_handle}})
{
push @{$db_uuids}, $db_uuid;
}
}
foreach my $db_uuid (@{$db_uuids})
{
my $count = $anvil->Database->query({debug => 2, uuid => $db_uuid, query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's2:db_uuid' => $db_uuid,
's2:count' => $count,
}});
if (not $count)
{
$hosts_ok = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { hosts_ok => $hosts_ok }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "warning_0144", variables => {
state_info => $state_name." -> ".$state_note,
db_uuid => $db_uuid,
host_uuid => $state_host_uuid,
}});
}
}
if (not $hosts_ok)
{
# Don't save.
return("");
}
# If we don't have a UUID, see if we can find one for the given state server name. # If we don't have a UUID, see if we can find one for the given state server name.
if (not $state_uuid) if (not $state_uuid)
{ {

@ -3132,6 +3132,7 @@ We will sleep a bit and try again.
<key name="warning_0141">[ Warning ] - We waited for: [#!variable!wait_time!#] seconds for all users of the local database to exit. Giving up waiting and taking the database down now.</key> <key name="warning_0141">[ Warning ] - We waited for: [#!variable!wait_time!#] seconds for all users of the local database to exit. Giving up waiting and taking the database down now.</key>
<key name="warning_0142">[ Warning ] - The command: [#!variable!command!#] is still using our database.</key> <key name="warning_0142">[ Warning ] - The command: [#!variable!command!#] is still using our database.</key>
<key name="warning_0143">[ Warning ] - While evaluating database shutdown, the host UUID: [#!variable!host_uuid!#] was not yet found in the database on host: [#!variable!db_uuid!#]. DB shutdown will not happen until all hosts are in all DBs.</key> <key name="warning_0143">[ Warning ] - While evaluating database shutdown, the host UUID: [#!variable!host_uuid!#] was not yet found in the database on host: [#!variable!db_uuid!#]. DB shutdown will not happen until all hosts are in all DBs.</key>
<key name="warning_0144">[ Warning ] - While preparing to record the state: [#!variable!state_info!#], the host UUID: [#!variable!host_uuid!#] was not yet found in the database on host: [#!variable!db_uuid!#]. NOT recording the state!</key>
<!-- The entries below here are not sequential, but use a key to find the entry. --> <!-- The entries below here are not sequential, but use a key to find the entry. -->
<!-- Run 'striker-parse-os-list to find new entries. --> <!-- Run 'striker-parse-os-list to find new entries. -->

Loading…
Cancel
Save