From e483840ceb3234a4e32e469d43fbd7561060bfaf Mon Sep 17 00:00:00 2001 From: digimer Date: Mon, 1 May 2023 20:29:20 -0400 Subject: [PATCH] Second attempt to fix the storage group race condition. This time, we only let node 1 assemble storage groups. Signed-off-by: digimer --- Anvil/Tools/Cluster.pm | 3 --- Anvil/Tools/Get.pm | 23 +++++++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Anvil/Tools/Cluster.pm b/Anvil/Tools/Cluster.pm index 34ac84b7..5fac82fe 100644 --- a/Anvil/Tools/Cluster.pm +++ b/Anvil/Tools/Cluster.pm @@ -379,9 +379,6 @@ ORDER BY scan_lvm_vg_internal_uuid => $scan_lvm_vg_internal_uuid, }}); - # Using previously loaded storage group data can be racy, so query group membership directly. - $anvil->Database->get_storage_group_data({debug => $debug}); - # Skip VGs that are in a group already. if ((exists $anvil->data->{storage_groups}{vg_uuid}{$scan_lvm_vg_internal_uuid}) && ($anvil->data->{storage_groups}{vg_uuid}{$scan_lvm_vg_internal_uuid}{storage_group_uuid})) diff --git a/Anvil/Tools/Get.pm b/Anvil/Tools/Get.pm index 0ec80857..7a566660 100644 --- a/Anvil/Tools/Get.pm +++ b/Anvil/Tools/Get.pm @@ -516,20 +516,27 @@ sub available_resources $anvil->Database->get_bridges({debug => $debug}); # Get the details. + my $host_uuid = $anvil->Get->host_uuid; my $anvil_name = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_name}; my $node1_host_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_node1_host_uuid}; my $node2_host_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_node2_host_uuid}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - anvil_name => $anvil_name, - node1_host_uuid => $node1_host_uuid, - node2_host_uuid => $node2_host_uuid, + 's1:anvil_name' => $anvil_name, + 's2:node1_host_uuid' => $node1_host_uuid, + 's3:node2_host_uuid' => $node2_host_uuid, + 's4:host_uuid' => $host_uuid, }}); - # This both loads storage group data and assembles ungrouped VGs into storage groups, when possible. - $anvil->Cluster->assemble_storage_groups({ - debug => 2, - anvil_uuid => $anvil_uuid, - }); + # If we're node 1, we'll try to assemble the storage group. Onle node 1 does this to help avoid race + # conditions. This both loads storage group data and assembles ungrouped VGs into storage groups, + # when possible. + if ($host_uuid eq $node1_host_uuid) + { + $anvil->Cluster->assemble_storage_groups({ + debug => 2, + anvil_uuid => $anvil_uuid, + }); + } # This will store the available resources based on the least of the nodes. $anvil->data->{anvil_resources}{$anvil_uuid}{cpu}{cores} = 0;