Added a check to avoid deep recursions when testing DB access

Signed-off-by: Madison Kelly <mkelly@alteeve.com>
main
Madison Kelly 7 months ago
parent 9cb2446bea
commit 52643885d2
  1. 25
      Anvil/Tools/Database.pm

@ -10732,6 +10732,7 @@ AND
{ {
$found = 1; $found = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { found => $found }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { found => $found }});
last;
} }
} }
if (not $found) if (not $found)
@ -10776,7 +10777,7 @@ INSERT INTO
); );
"; ";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__}); $anvil->Database->write({debug => $debug, uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
} }
else else
{ {
@ -18018,13 +18019,14 @@ sub reconnect
my $parameter = shift; my $parameter = shift;
my $anvil = $self->parent; my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->resync_databases()" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->reconnect()" }});
# Close our own connection. # Close our own connection.
$anvil->Database->locking({debug => $debug, release => 1}); $anvil->Database->locking({debug => $debug, release => 1});
# Disconnect from all databases and then stop the daemon, then reconnect. # Disconnect from all databases and then stop the daemon, then reconnect.
$anvil->Database->disconnect({debug => $debug}); $anvil->Database->disconnect({debug => $debug});
sleep 2;
# Refresh configs. # Refresh configs.
$anvil->refresh(); $anvil->refresh();
@ -20746,6 +20748,15 @@ sub _test_access
alarm(0); alarm(0);
if (not $connected) if (not $connected)
{ {
if ((not exists $anvil->data->{sys}{in_test_access}) or (not $anvil->data->{sys}{in_test_access}))
{
# This prevents deep recursion
$anvil->data->{sys}{in_test_access} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::in_test_access" => $anvil->data->{sys}{in_test_access},
}});
# Tell the user we're going to try to reconnect
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0192", variables => { server => $say_server }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0192", variables => { server => $say_server }});
# Try to reconnect. # Try to reconnect.
@ -20755,6 +20766,11 @@ sub _test_access
"cache::database_handle::${uuid}" => $anvil->data->{cache}{database_handle}{$uuid}, "cache::database_handle::${uuid}" => $anvil->data->{cache}{database_handle}{$uuid},
}}); }});
$anvil->data->{sys}{in_test_access} = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::in_test_access" => $anvil->data->{sys}{in_test_access},
}});
if ($anvil->data->{cache}{database_handle}{$uuid}) if ($anvil->data->{cache}{database_handle}{$uuid})
{ {
alarm(120); alarm(120);
@ -20786,6 +20802,11 @@ sub _test_access
return($problem); return($problem);
} }
} }
else
{
# No luck.
}
}
# Success! # Success!
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0088"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0088"});

Loading…
Cancel
Save