Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarketCap calculation: check that ETS tables exist before inserting new data or lookup from the table #3335

Merged
merged 1 commit into from
Oct 8, 2020

Conversation

vbaranov
Copy link
Member

@vbaranov vbaranov commented Oct 7, 2020

Motivation

The appearance of error like this

Request: GET /
** (exit) an exception was raised:
    ** (ArgumentError) argument error
        (stdlib 3.12.1) :ets.insert(:bridges_market_cap, {"current_market_cap_from_omni_bridge", #Decimal<0E-18>})
        (explorer 0.0.1) lib/explorer/counters/bridge.ex:152: Explorer.Counters.Bridge.update_total_omni_bridge_market_cap_cache/0
        (explorer 0.0.1) lib/explorer/chain/supply/token_bridge.ex:60: Explorer.Chain.Supply.TokenBridge.market_cap/1
        (block_scout_web 0.0.1) lib/block_scout_web/templates/chain/show.html.eex:66: BlockScoutWeb.ChainView."show.html"/1
        (phoenix 1.5.4) lib/phoenix/view.ex:310: Phoenix.View.render_within/3
        (phoenix 1.5.4) lib/phoenix/view.ex:472: Phoenix.View.render_to_iodata/3
        (phoenix 1.5.4) lib/phoenix/controller.ex:776: Phoenix.Controller.render_and_send/4
        (block_scout_web 0.0.1) lib/block_scout_web/controllers/chain_controller.ex:1: BlockScoutWeb.ChainController.action/2
2020-10-07T13:47:23.725 [error] Task Explorer.ExchangeRates started from #PID<0.23441.0> terminating

Changelog

Before inserting or lookup in ETS table, check that ETS table exists. Sometimes due to race conditions initialization of the process which creates those tables happens later than searching from/insertion to those tables requested from other processes.

Checklist for your Pull Request (PR)

@vbaranov vbaranov changed the title Check that ETS tables exists before inserting new data or lookup from the table MarketCap calculation: check that ETS tables exist before inserting new data or lookup from the table Oct 7, 2020
@vbaranov vbaranov force-pushed the vb-safely-check-ets-table-exist-for-market-cap branch from 392ef7e to dc8f49a Compare October 7, 2020 15:05
@coveralls
Copy link

coveralls commented Oct 7, 2020

Pull Request Test Coverage Report for Build dc8f49a48b46f5391c5a999d050bd7912e5a2a37-PR-3335

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 8 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+6.8%) to 74.369%

Files with Coverage Reduction New Missed Lines %
lib/block_scout_web/channels/address_channel.ex 2 36.96%
lib/block_scout_web/checksum_address.ex 6 55.56%
Totals Coverage Status
Change from base Build d2ec9d28e5c68453ab422ebd5f2373affd5d91ca: 6.8%
Covered Lines: 1973
Relevant Lines: 2653

💛 - Coveralls

@vbaranov vbaranov merged commit 5058122 into master Oct 8, 2020
@vbaranov vbaranov deleted the vb-safely-check-ets-table-exist-for-market-cap branch October 8, 2020 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants