* Updated Database->connect to clean up duplicates on setting the read UUID and database handle.

Signed-off-by: digimer <digimer@gravitar.alteeve.com>
main
digimer 2 years ago
parent 26a1fe1491
commit 3d6f71f27e
  1. 43
      Anvil/Tools/Database.pm
  2. 1
      Anvil/Tools/Get.pm

@ -1614,15 +1614,24 @@ sub connect
}}); }});
# Set this database handle as the one to use for reading, if no handle is yet set. # Set this database handle as the one to use for reading, if no handle is yet set.
if (not $anvil->Database->read) if (($is_local) or (not $anvil->data->{sys}{database}{read_uuid}) or (not $anvil->Database->read))
{ {
$anvil->data->{sys}{database}{read_uuid} = $uuid;
$anvil->Database->read({set => $dbh}); $anvil->Database->read({set => $dbh});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'anvil->Database->read' => $anvil->Database->read }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
'anvil->Database->read' => $anvil->Database->read,
"sys::database::read_uuid" => $anvil->data->{sys}{database}{read_uuid},
}});
} }
if (not $anvil->data->{sys}{database}{read_uuid})
# Only the first database to connect will be "Active". What this means will expand
# over time. As of now, only the active DB will do resyncs.
if (not $anvil->data->{sys}{database}{active_uuid})
{ {
$anvil->data->{sys}{database}{read_uuid} = $uuid; $anvil->data->{sys}{database}{active_uuid} = $uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "sys::database::read_uuid" => $anvil->data->{sys}{database}{read_uuid} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::database::active_uuid" => $anvil->data->{sys}{database}{active_uuid},
}});
} }
# Read the DB identifier and then check that we've not already connected to this DB. # Read the DB identifier and then check that we've not already connected to this DB.
@ -1739,30 +1748,6 @@ sub connect
"db_status::${uuid}::active" => $anvil->data->{db_status}{$uuid}{active}, "db_status::${uuid}::active" => $anvil->data->{db_status}{$uuid}{active},
}}); }});
# We always use the first DB we connect to, unless we've got a local DB. We always
# prefer local as there could be data locally that hasn't yet been sync'ed with the
# peer.
if (($is_local) or (not $anvil->data->{sys}{database}{read_uuid}))
{
$anvil->data->{sys}{database}{read_uuid} = $uuid;
$anvil->Database->read({set => $anvil->data->{cache}{database_handle}{$uuid}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::database::read_uuid" => $anvil->data->{sys}{database}{read_uuid},
'anvil->Database->read' => $anvil->Database->read(),
}});
}
# Only the first database to connect will be "Active". What this means will expand
# over time. As of now, only the active DB will do resyncs.
if (not $anvil->data->{sys}{database}{active_uuid})
{
$anvil->data->{sys}{database}{active_uuid} = $uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::database::active_uuid" => $anvil->data->{sys}{database}{active_uuid},
}});
}
# Get a time stamp for this run, if not yet gotten. # Get a time stamp for this run, if not yet gotten.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"cache::database_handle::${uuid}" => $anvil->data->{cache}{database_handle}{$uuid}, "cache::database_handle::${uuid}" => $anvil->data->{cache}{database_handle}{$uuid},

@ -2417,6 +2417,7 @@ sub switches
foreach my $set_switch (sort {$a cmp $b} keys %{$anvil->data->{switches}}) foreach my $set_switch (sort {$a cmp $b} keys %{$anvil->data->{switches}})
{ {
next if $set_switch eq "?"; next if $set_switch eq "?";
next if $set_switch eq "age-out-database";
next if $set_switch eq "h"; next if $set_switch eq "h";
next if $set_switch eq "help"; next if $set_switch eq "help";
next if $set_switch eq "job-uuid"; next if $set_switch eq "job-uuid";

Loading…
Cancel
Save