From c61c29a0073cd991cb8cc7e2b76b65e87f46badd Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Fri, 22 Jul 2022 14:06:01 +0300 Subject: [PATCH] limit query of outstanding blocks to 500k --- CHANGELOG.md | 1 + apps/explorer/lib/explorer/chain.ex | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f898f69f0a..6428e52e79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#5699](https://github.com/blockscout/blockscout/pull/5699) - Switch to basic (non-pro) API endpoint for Coingecko requests, if API key is not provided ### Fixes +- [#5768](https://github.com/blockscout/blockscout/pull/5768) - Outstanding rows limit for missing blocks query (catchup fetcher) - [#5737](https://github.com/blockscout/blockscout/pull/5737) - Fix double requests; Fix token balances dropdown view - [#5723](https://github.com/blockscout/blockscout/pull/5723) - Add nil clause for Data.to_string/1 - [#5714](https://github.com/blockscout/blockscout/pull/5714) - Add clause for EthereumJSONRPC.Transaction.elixir_to_params/1 when gas_price is missing in the response diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 79cf9e1b95..71da0dcaa2 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2987,10 +2987,14 @@ defmodule Explorer.Chain do right_join: missing_range in fragment( """ - (SELECT distinct b1.number + ( + SELECT distinct b1.number FROM generate_series((?)::integer, (?)::integer) AS b1(number) WHERE NOT EXISTS - (SELECT 1 FROM blocks b2 WHERE b2.number=b1.number AND b2.consensus)) + (SELECT 1 FROM blocks b2 WHERE b2.number=b1.number AND b2.consensus) + ORDER BY b1.number DESC + LIMIT 500000 + ) """, ^range_min, ^range_max