Merge pull request #5369 from blockscout/vb-manage-memory-limit

Manage indexer memory limit
pull/5399/head
Victor Baranov 3 years ago committed by GitHub
commit b05088130a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .dialyzer-ignore
  2. 1
      CHANGELOG.md
  3. 6
      apps/block_scout_web/config/config.exs
  4. 2
      apps/block_scout_web/config/dev.exs
  5. 2
      apps/block_scout_web/config/prod.exs
  6. 2
      apps/block_scout_web/config/test.exs
  7. 4
      apps/ethereum_jsonrpc/config/config.exs
  8. 2
      apps/ethereum_jsonrpc/config/dev.exs
  9. 2
      apps/ethereum_jsonrpc/config/prod.exs
  10. 2
      apps/ethereum_jsonrpc/config/test.exs
  11. 6
      apps/explorer/config/config.exs
  12. 2
      apps/explorer/config/dev.exs
  13. 2
      apps/explorer/config/dev/arbitrum.exs
  14. 2
      apps/explorer/config/dev/besu.exs
  15. 2
      apps/explorer/config/dev/ganache.exs
  16. 2
      apps/explorer/config/dev/geth.exs
  17. 2
      apps/explorer/config/dev/parity.exs
  18. 2
      apps/explorer/config/dev/rsk.exs
  19. 2
      apps/explorer/config/prod.exs
  20. 2
      apps/explorer/config/prod/arbitrum.exs
  21. 2
      apps/explorer/config/prod/besu.exs
  22. 2
      apps/explorer/config/prod/ganache.exs
  23. 2
      apps/explorer/config/prod/geth.exs
  24. 2
      apps/explorer/config/prod/parity.exs
  25. 2
      apps/explorer/config/prod/rsk.exs
  26. 2
      apps/explorer/config/test.exs
  27. 2
      apps/explorer/config/test/arbitrum.exs
  28. 2
      apps/explorer/config/test/besu.exs
  29. 2
      apps/explorer/config/test/ganache.exs
  30. 2
      apps/explorer/config/test/geth.exs
  31. 2
      apps/explorer/config/test/parity.exs
  32. 2
      apps/explorer/config/test/rsk.exs
  33. 10
      apps/indexer/config/config.exs
  34. 2
      apps/indexer/config/dev.exs
  35. 2
      apps/indexer/config/dev/arbitrum.exs
  36. 2
      apps/indexer/config/dev/besu.exs
  37. 2
      apps/indexer/config/dev/ganache.exs
  38. 2
      apps/indexer/config/dev/geth.exs
  39. 2
      apps/indexer/config/dev/parity.exs
  40. 2
      apps/indexer/config/dev/rsk.exs
  41. 2
      apps/indexer/config/prod.exs
  42. 2
      apps/indexer/config/prod/arbitrum.exs
  43. 2
      apps/indexer/config/prod/besu.exs
  44. 2
      apps/indexer/config/prod/ganache.exs
  45. 2
      apps/indexer/config/prod/geth.exs
  46. 2
      apps/indexer/config/prod/parity.exs
  47. 2
      apps/indexer/config/prod/rsk.exs
  48. 2
      apps/indexer/config/test.exs
  49. 2
      apps/indexer/config/test/arbitrum.exs
  50. 2
      apps/indexer/config/test/besu.exs
  51. 2
      apps/indexer/config/test/ganache.exs
  52. 2
      apps/indexer/config/test/geth.exs
  53. 2
      apps/indexer/config/test/parity.exs
  54. 2
      apps/indexer/config/test/rsk.exs
  55. 2
      apps/indexer/lib/indexer/empty_blocks_sanitizer.ex
  56. 3
      apps/indexer/lib/indexer/memory/monitor.ex
  57. 10
      config/config.exs
  58. 2
      config/dev.exs
  59. 2
      config/prod.exs
  60. 15
      config/runtime.exs
  61. 2
      config/test.exs
  62. 3
      docker/Makefile
  63. 34
      mix.exs
  64. 4
      rel/config.exs

@ -34,4 +34,4 @@ lib/block_scout_web/views/transaction_view.ex:152
lib/block_scout_web/views/transaction_view.ex:197
lib/indexer/buffered_task.ex:402
lib/indexer/buffered_task.ex:451
lib/indexer/memory/monitor.ex:161
lib/indexer/memory/monitor.ex:160

@ -24,6 +24,7 @@
- [#5239](https://github.com/blockscout/blockscout/pull/5239) - Add accounting for block rewards in `getblockreward` api method
### Chore
- [#5369](https://github.com/blockscout/blockscout/pull/5369) - Manage indexer memory limit
- [#5368](https://github.com/blockscout/blockscout/pull/5368) - Refactoring from SourcifyFilePathBackfiller
- [#5367](https://github.com/blockscout/blockscout/pull/5367) - Resolve Prototype Pollution in minimist dependency
- [#5366](https://github.com/blockscout/blockscout/pull/5366) - Fix Vyper smart-contract verification form tooltips

@ -1,9 +1,9 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
# and its dependencies with the aid of the Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
use Mix.Config
import Config
# General application configuration
config :block_scout_web,
@ -183,4 +183,4 @@ config :hammer,
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
import_config "#{config_env()}.exs"

@ -1,4 +1,4 @@
use Mix.Config
import Config
# For development, we disable any cache and enable
# debugging and code reloading.

@ -1,4 +1,4 @@
use Mix.Config
import Config
# For production, we often load configuration from external
# sources, such as your system environment. For this reason,

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :block_scout_web, :sql_sandbox, true

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :ethereum_jsonrpc, EthereumJSONRPC.RequestCoordinator,
rolling_window_opts: [
@ -36,4 +36,4 @@ config :logger, :ethereum_jsonrpc,
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
import_config "#{config_env()}.exs"

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :ethereum_jsonrpc, EthereumJSONRPC.Tracer, env: "dev", disabled?: true

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :ethereum_jsonrpc, EthereumJSONRPC.Tracer, env: "production", disabled?: true

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :ethereum_jsonrpc, EthereumJSONRPC.RequestCoordinator,
rolling_window_opts: [

@ -1,9 +1,9 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
# and its dependencies with the aid of the Config module.
#
# This configuration file is loaded before any dependency and
# is restricted to this project.
use Mix.Config
import Config
# General application configuration
config :explorer,
@ -256,4 +256,4 @@ config :explorer, Explorer.ThirdPartyIntegrations.Sourcify,
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
import_config "#{config_env()}.exs"

@ -1,4 +1,4 @@
use Mix.Config
import Config
database = if System.get_env("DATABASE_URL"), do: nil, else: "explorer_dev"
hostname = if System.get_env("DATABASE_URL"), do: nil, else: "localhost"

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
pool_size =
if System.get_env("DATABASE_READ_ONLY_API_URL"),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
# Lower hashing rounds for faster tests
config :bcrypt_elixir, log_rounds: 4

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
transport: EthereumJSONRPC.HTTP,

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
transport: EthereumJSONRPC.HTTP,

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :explorer,
transport: EthereumJSONRPC.HTTP,

@ -1,8 +1,6 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
import Bitwise
# and its dependencies with the aid of the Config module.
import Config
block_transformers = %{
"clique" => Indexer.Transform.Blocks.Clique,
@ -33,8 +31,6 @@ config :indexer,
ecto_repos: [Explorer.Repo],
metadata_updater_seconds_interval:
String.to_integer(System.get_env("TOKEN_METADATA_UPDATE_INTERVAL") || "#{2 * 24 * 60 * 60}"),
# bytes
memory_limit: 1 <<< 30,
first_block: System.get_env("FIRST_BLOCK") || "",
last_block: System.get_env("LAST_BLOCK") || "",
trace_first_block: System.get_env("TRACE_FIRST_BLOCK") || "",
@ -96,4 +92,4 @@ config :logger, :indexer,
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
import_config "#{config_env()}.exs"

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer, Indexer.Tracer, env: "dev", disabled?: true

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer, Indexer.Tracer, env: "production", disabled?: true

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
block_interval: :timer.seconds(5),

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer, Indexer.Tracer, disabled?: false

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
json_rpc_named_arguments: [

@ -1,4 +1,4 @@
use Mix.Config
import Config
config :indexer,
json_rpc_named_arguments: [

@ -16,7 +16,7 @@ defmodule Indexer.EmptyBlocksSanitizer do
alias Explorer.Chain.{Block, Transaction}
alias Explorer.Chain.Import.Runner.Blocks
# unprocessed emty blocks to fetch at once
# unprocessed empty blocks to fetch at once
@limit 1000
@interval :timer.minutes(1)

@ -10,12 +10,11 @@ defmodule Indexer.Memory.Monitor do
require Bitwise
require Logger
import Bitwise
import Indexer.Logger, only: [process: 1]
alias Indexer.Memory.Shrinkable
defstruct limit: 1 <<< 30,
defstruct limit: Application.get_env(:indexer, :memory_limit),
timer_interval: :timer.minutes(1),
timer_reference: nil,
shrinkable_set: MapSet.new()

@ -1,13 +1,15 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
# and its dependencies with the aid of the Config module.
import Config
# By default, the umbrella project as well as each child
# application will require this configuration file, ensuring
# they all use the same configuration. While one could
# configure all applications here, we prefer to delegate
# back to each application for organization purposes.
import_config "../apps/*/config/config.exs"
for config <- "../apps/*/config/config.exs" |> Path.expand(__DIR__) |> Path.wildcard() do
import_config config
end
config :phoenix, :json_library, Jason
@ -60,4 +62,4 @@ config :logger, :error,
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"
import_config "#{config_env()}.exs"

@ -1,4 +1,4 @@
use Mix.Config
import Config
# DO NOT make it `:debug` or all Ecto logs will be shown for indexer
config :logger, :console, level: :info

@ -1,4 +1,4 @@
use Mix.Config
import Config
# Do not print debug messages in production

@ -0,0 +1,15 @@
import Config
import Bitwise
indexer_memory_limit =
"INDEXER_MEMORY_LIMIT"
|> System.get_env("1")
|> Integer.parse()
|> case do
{integer, ""} -> integer
_ -> 1
end
config :indexer,
memory_limit: indexer_memory_limit <<< 30

@ -1,4 +1,4 @@
use Mix.Config
import Config
# Print only warnings and errors during test

@ -392,6 +392,9 @@ endif
ifdef COIN_BALANCE_ON_DEMAND_FETCHER_THRESHOLD_MINUTES
BLOCKSCOUT_CONTAINER_PARAMS += -e 'COIN_BALANCE_ON_DEMAND_FETCHER_THRESHOLD_MINUTES=$(COIN_BALANCE_ON_DEMAND_FETCHER_THRESHOLD_MINUTES)'
endif
ifdef INDEXER_MEMORY_LIMIT
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_MEMORY_LIMIT=$(INDEXER_MEMORY_LIMIT)'
endif
HAS_BLOCKSCOUT_IMAGE := $(shell docker images | grep -sw "${BS_CONTAINER_IMAGE} ")
build:

@ -6,7 +6,7 @@ defmodule BlockScout.Mixfile do
def project do
[
app: :block_scout,
aliases: aliases(Mix.env()),
# aliases: aliases(config_env()),
version: "4.1.2",
apps_path: "apps",
deps: deps(),
@ -16,7 +16,7 @@ defmodule BlockScout.Mixfile do
credo: :test,
dialyzer: :test
],
start_permanent: Mix.env() == :prod,
# start_permanent: config_env() == :prod,
releases: [
blockscout: [
applications: [
@ -42,23 +42,23 @@ defmodule BlockScout.Mixfile do
]
end
defp aliases(env) do
[
# to match behavior of `mix test` in `apps/indexer`, which needs to not start applications for `indexer` to
# prevent its supervision tree from starting, which is undesirable in test
test: "test --no-start"
] ++ env_aliases(env)
end
# defp aliases(env) do
# [
# # to match behavior of `mix test` in `apps/indexer`, which needs to not start applications for `indexer` to
# # prevent its supervision tree from starting, which is undesirable in test
# test: "test --no-start"
# ] ++ env_aliases(env)
# end
defp env_aliases(:dev) do
[]
end
# defp env_aliases(:dev) do
# []
# end
defp env_aliases(_env) do
[
compile: "compile --warnings-as-errors"
]
end
# defp env_aliases(_env) do
# [
# compile: "compile --warnings-as-errors"
# ]
# end
# Dependencies can be Hex packages:
#

@ -1,3 +1,5 @@
import Config
# Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to
# either an environment, or release definition, where
@ -33,7 +35,7 @@ use Mix.Releases.Config,
# This sets the default release built by `mix release`
default_release: :default,
# This sets the default environment used by `mix release`
default_environment: Mix.env()
default_environment: config_env()
# For a full list of config options for both releases
# and environments, visit https://hexdocs.pm/distillery/config/distillery.html

Loading…
Cancel
Save