From f1752d972d57d54118649ac7cdf9dee1079872b3 Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop <105209995+Qwerty5Uiop@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:48:43 +0400 Subject: [PATCH] fix: Add no overlapping constraint to missing_block_ranges (#10449) --- ...3_add_no_overlap_index_to_missing_block_ranges.exs | 11 +++++++++++ .../block/catchup/missing_ranges_collector_test.exs | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 apps/explorer/priv/repo/migrations/20240718150123_add_no_overlap_index_to_missing_block_ranges.exs diff --git a/apps/explorer/priv/repo/migrations/20240718150123_add_no_overlap_index_to_missing_block_ranges.exs b/apps/explorer/priv/repo/migrations/20240718150123_add_no_overlap_index_to_missing_block_ranges.exs new file mode 100644 index 0000000000..7f569610b1 --- /dev/null +++ b/apps/explorer/priv/repo/migrations/20240718150123_add_no_overlap_index_to_missing_block_ranges.exs @@ -0,0 +1,11 @@ +defmodule Explorer.Repo.Migrations.AddNoOverlapIndexToMissingBlockRanges do + use Ecto.Migration + + def change do + create( + constraint(:missing_block_ranges, :missing_block_ranges_no_overlap, + exclude: ~s|gist (int4range(to_number, from_number, '[]') WITH &&)| + ) + ) + end +end diff --git a/apps/indexer/test/indexer/block/catchup/missing_ranges_collector_test.exs b/apps/indexer/test/indexer/block/catchup/missing_ranges_collector_test.exs index 77449d9004..a53a7d3063 100644 --- a/apps/indexer/test/indexer/block/catchup/missing_ranges_collector_test.exs +++ b/apps/indexer/test/indexer/block/catchup/missing_ranges_collector_test.exs @@ -38,9 +38,9 @@ defmodule Indexer.Block.Catchup.MissingRangesCollectorTest do Application.put_env(:indexer, :last_block, 200) insert(:missing_block_range, from_number: 250, to_number: 220) - insert(:missing_block_range, from_number: 220, to_number: 190) + insert(:missing_block_range, from_number: 219, to_number: 190) insert(:missing_block_range, from_number: 120, to_number: 90) - insert(:missing_block_range, from_number: 90, to_number: 80) + insert(:missing_block_range, from_number: 89, to_number: 80) MissingRangesCollector.start_link([]) Process.sleep(500)