From 26a1fe1491b7c9ff6682e0beb50ffa27efd18f50 Mon Sep 17 00:00:00 2001 From: digimer Date: Wed, 18 Jan 2023 15:47:34 -0500 Subject: [PATCH] * Updated Database->connect() to allow local reads on strikers, regardless of the active DB. Signed-off-by: digimer --- Anvil/Tools/Database.pm | 7 ++++--- Anvil/Tools/System.pm | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index b4604960..c9780719 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -1739,9 +1739,10 @@ sub connect "db_status::${uuid}::active" => $anvil->data->{db_status}{$uuid}{active}, }}); - # We always use the first DB we connect to, even if we're a DB ourselves. This helps - # with consistency and leaves second (or third...) as backups. - if (not $anvil->data->{sys}{database}{read_uuid}) + # 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}}); diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm index 3e319ef7..ea6520d0 100644 --- a/Anvil/Tools/System.pm +++ b/Anvil/Tools/System.pm @@ -630,6 +630,7 @@ sub check_if_configured { # Write the database entry. my $variable_uuid = $anvil->Database->insert_or_update_variables({ + debug => 2, variable_name => "system::configured", variable_value => 1, variable_default => "",