From 20bbb455579a90f504c770c5de84f65b153ad766 Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop Date: Wed, 17 May 2023 13:36:28 +0400 Subject: [PATCH] Fix MissingRangesManipulator --- CHANGELOG.md | 2 +- apps/indexer/lib/indexer/block/catchup/fetcher.ex | 4 +--- .../block/catchup/missing_ranges_manipulator.ex | 13 ++++--------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b1d2d5aae..27ca68db16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ - [#7355](https://github.com/blockscout/blockscout/pull/7355) - Add endpoint for token info import - [#7393](https://github.com/blockscout/blockscout/pull/7393) - Realtime fetcher max gap - [#7436](https://github.com/blockscout/blockscout/pull/7436) - TokenBalanceOnDemand ERC-1155 support -- [#7469](https://github.com/blockscout/blockscout/pull/7469), [#7485](https://github.com/blockscout/blockscout/pull/7485) - Clear missing block ranges after every success import +- [#7469](https://github.com/blockscout/blockscout/pull/7469), [#7485](https://github.com/blockscout/blockscout/pull/7485), [#7493](https://github.com/blockscout/blockscout/pull/7493) - Clear missing block ranges after every success import - [#7489](https://github.com/blockscout/blockscout/pull/7489) - INDEXER_CATCHUP_BLOCK_INTERVAL env var ### Fixes diff --git a/apps/indexer/lib/indexer/block/catchup/fetcher.ex b/apps/indexer/lib/indexer/block/catchup/fetcher.ex index 0f15cedca2..341965c9fb 100644 --- a/apps/indexer/lib/indexer/block/catchup/fetcher.ex +++ b/apps/indexer/lib/indexer/block/catchup/fetcher.ex @@ -75,8 +75,6 @@ defmodule Indexer.Block.Catchup.Fetcher do shrunk = Shrinkable.shrunk?(sequence) - MissingRangesManipulator.clear_batch(missing_ranges) - %{ first_block_number: first, last_block_number: last, @@ -275,7 +273,7 @@ defmodule Indexer.Block.Catchup.Fetcher do success_numbers |> numbers_to_ranges() - |> Enum.map(&MissingRangesManipulator.delete_range/1) + |> MissingRangesManipulator.clear_batch() end defp block_errors_to_block_number_ranges(block_errors) when is_list(block_errors) do diff --git a/apps/indexer/lib/indexer/block/catchup/missing_ranges_manipulator.ex b/apps/indexer/lib/indexer/block/catchup/missing_ranges_manipulator.ex index 64dcac267a..d4ddc2b0ae 100644 --- a/apps/indexer/lib/indexer/block/catchup/missing_ranges_manipulator.ex +++ b/apps/indexer/lib/indexer/block/catchup/missing_ranges_manipulator.ex @@ -16,12 +16,9 @@ defmodule Indexer.Block.Catchup.MissingRangesManipulator do GenServer.call(__MODULE__, :get_latest_batch) end - def delete_range(range) do - GenServer.cast(__MODULE__, {:delete_range, range}) - end - + @timeout_by_range 2000 def clear_batch(batch) do - GenServer.cast(__MODULE__, {:clear_batch, batch}) + GenServer.call(__MODULE__, {:clear_batch, batch}, @timeout_by_range * Enum.count(batch)) end @impl true @@ -42,9 +39,7 @@ defmodule Indexer.Block.Catchup.MissingRangesManipulator do {:noreply, state} end - def handle_cast({:clear_batch, batch}, state) do - MissingBlockRange.clear_batch(batch) - - {:noreply, state} + def handle_call({:clear_batch, batch}, _from, state) do + {:reply, MissingBlockRange.clear_batch(batch), state} end end