Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: update_node_network_patch with nil #1136

Closed
bchamagne opened this issue Jun 30, 2023 · 1 comment · Fixed by #1145
Closed

Bug: update_node_network_patch with nil #1136

bchamagne opened this issue Jun 30, 2023 · 1 comment · Fixed by #1145
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bchamagne
Copy link
Contributor

Describe the problem you discovered

Scenario:

  1. Start 4 nodes
  2. Wait for them to be all globally available
  3. Stop 2 node
  4. Start them again

We get this error:

** (Mix) Could not start application archethic: Archethic.Application.start(:normal, []) returned an error: shutdown: failed to start child: Archethic.P2P.Supervisor
    ** (EXIT) shutdown: failed to start child: Archethic.P2P.MemTableLoader
        ** (EXIT) an exception was raised:
            ** (FunctionClauseError) no function clause matching in Archethic.P2P.MemTable.update_node_network_patch/2
                (archethic 1.2.2) lib/archethic/p2p/mem_table.ex:853: Archethic.P2P.MemTable.update_node_network_patch(<<0, 1, 29, 150, 125, 113, 178, 225, 53, 200, 66, 6, 221, 209, 8, 181, 146, 90, 44, 217, 156, 142, 188, 90, 181, 216, 253, 46, 201, 64, 12, 227, 201, 138>>, nil)
                (archethic 1.2.2) lib/archethic/p2p/mem_table_loader.ex:183: Archethic.P2P.MemTableLoader.load_p2p_summary/1
                (elixir 1.14.1) lib/enum.ex:975: Enum."-each/2-lists^foreach/1-0-"/2
                (archethic 1.2.2) lib/archethic/p2p/mem_table_loader.ex:55: Archethic.P2P.MemTableLoader.init/1
                (stdlib 4.1.1) gen_server.erl:851: :gen_server.init_it/2
                (stdlib 4.1.1) gen_server.erl:814: :gen_server.init_it/6
                (stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

Describe the solution you'd like

Looks like it's because the beacon summaries does not have network_patches:

   ...
   p2p_availabilities: %{
     <<29>> => %{
       end_of_node_synchronizations: [],
       network_patches: [],
       node_availabilities: <<1::size(1)>>,
       node_average_availabilities: [1.0]
     },
     "q" => %{
       end_of_node_synchronizations: [
         <<0, 1, 113, 73, 96, 150, 88, 74, 154, 18, 220, 37, 55, 15, 213, 73,
           12, 181, 177, 46, 110, 10, 65, 229, 206, 179, 124, 164, 71, 182, 153,
           77, 7, 242>>
       ],
       network_patches: [],
       node_availabilities: <<1::size(1)>>,
       node_average_availabilities: [0.96]
     },
     <<190>> => %{
       end_of_node_synchronizations: [
         <<0, 1, 190, 20, 188, 141, 156, 135, 91, 37, 96, 187, 27, 24, 41, 130,
           118, 93, 43, 240, 229, 97, 227, 194, 31, 97, 228, 78, 156, 194, 154,
           74, 160, 104>>
       ],
       network_patches: [],
       node_availabilities: <<1::size(1)>>,
       node_average_availabilities: [0.98]
     },
     <<221>> => %{
       end_of_node_synchronizations: [
         <<0, 1, 221, 229, 74, 49, 62, 93, 205, 115, 228, 19, 116, 140, 191,
           102, 121, 240, 119, 23, 248, 189, 198, 108, 190, 143, 152, 30, 30,
           71, 90, 152, 96, 92>>
       ],
       network_patches: [],
       node_availabilities: <<1::size(1)>>,
       node_average_availabilities: [0.89]
     }
   }

Epic

No response

@bchamagne bchamagne added the bug Something isn't working label Jun 30, 2023
@bchamagne bchamagne modified the milestones: 1.2.3, 1.3.0 Jun 30, 2023
@bchamagne
Copy link
Contributor Author

Fix proposal

diff --git a/lib/archethic/self_repair/sync.ex b/lib/archethic/self_repair/sync.ex
index 540c8c64..fcc13fae 100644
--- a/lib/archethic/self_repair/sync.ex
+++ b/lib/archethic/self_repair/sync.ex
@@ -379,7 +379,7 @@ defmodule Archethic.SelfRepair.Sync do
     |> Enum.reduce(acc, fn {available_bit, index}, acc ->
       node = Enum.at(subset_node_list, index)
       avg_availability = Enum.at(node_average_availabilities, index)
-      network_patch = Enum.at(network_patches, index)
+      network_patch = Enum.at(network_patches, index, node.geo_patch)
       available? = available_bit == 1 and node.synced?
 
       Map.put(acc, node, %{

@github-project-automation github-project-automation bot moved this to Todo 🚩 in Dev Board Jul 3, 2023
@Neylix Neylix self-assigned this Jul 3, 2023
@Neylix Neylix moved this from Todo 🚩 to In Progress 🚧 in Dev Board Jul 3, 2023
@Neylix Neylix linked a pull request Jul 3, 2023 that will close this issue
@Neylix Neylix moved this from In Progress 🚧 to Review 💬 in Dev Board Jul 3, 2023
@github-project-automation github-project-automation bot moved this from Review 💬 to Done 🍻 in Dev Board Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done 🍻
Development

Successfully merging a pull request may close this issue.

2 participants