From 0173d3d7f104825f0a038a0812e6c8c6423dc7a1 Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop Date: Thu, 19 Oct 2023 17:35:14 +0600 Subject: [PATCH] Add head offset for empty blocks sanitizer --- .../indexer/lib/indexer/fetcher/empty_blocks_sanitizer.ex | 8 ++++++-- config/runtime.exs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/indexer/lib/indexer/fetcher/empty_blocks_sanitizer.ex b/apps/indexer/lib/indexer/fetcher/empty_blocks_sanitizer.ex index 013ace680c..8d92ccdc57 100644 --- a/apps/indexer/lib/indexer/fetcher/empty_blocks_sanitizer.ex +++ b/apps/indexer/lib/indexer/fetcher/empty_blocks_sanitizer.ex @@ -15,6 +15,7 @@ defmodule Indexer.Fetcher.EmptyBlocksSanitizer do alias Ecto.Changeset alias Explorer.{Chain, Repo} alias Explorer.Chain.{Block, PendingBlockOperation, Transaction} + alias Explorer.Chain.Cache.BlockNumber alias Explorer.Chain.Import.Runner.Blocks @interval :timer.seconds(10) @@ -133,13 +134,16 @@ defmodule Indexer.Fetcher.EmptyBlocksSanitizer do {:error, %{exception: postgrex_error}} end + @head_offset 1000 defp consensus_blocks_with_nil_is_empty_query(limit) do + safe_block_number = BlockNumber.get_max() - @head_offset + from(block in Block, where: is_nil(block.is_empty), + where: block.number <= ^safe_block_number, where: block.consensus == true, order_by: [asc: block.hash], - limit: ^limit, - offset: 1000 + limit: ^limit ) end diff --git a/config/runtime.exs b/config/runtime.exs index 536f8bd441..ab0f0d9ea6 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -525,7 +525,7 @@ config :indexer, Indexer.Fetcher.TokenInstance.LegacySanitize.Supervisor, config :indexer, Indexer.Fetcher.EmptyBlocksSanitizer, batch_size: ConfigHelper.parse_integer_env_var("INDEXER_EMPTY_BLOCKS_SANITIZER_BATCH_SIZE", 100), - interval: ConfigHelper.parse_time_env_var("INDEXER_EMPTY_BLOCKS_SANITIZER_INTERVAL", "5m") + interval: ConfigHelper.parse_time_env_var("INDEXER_EMPTY_BLOCKS_SANITIZER_INTERVAL", "10s") config :indexer, Indexer.Block.Realtime.Fetcher, max_gap: ConfigHelper.parse_integer_env_var("INDEXER_REALTIME_FETCHER_MAX_GAP", 1000)