Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

blockchain_worker startup crash loop on non-following apps #1500

Description

@ke6jjj

Summary

Some apps that use blockchain-core without intending to follow the chain (e.g. the Helium miner) will receive a crash notice in blockchain_worker every 90 seconds after it attempts to start up. This is likely due to the code attempting to perform a delayed "cache pre-warm" on the local ledger, even if there is no local ledger being used.

Expected behavior

If an app has signaled to blockchain_worker that it is not a chain follower (application:get_env(blockchain, autoload) returns undefined or false), it should not attempt to pre-warm the ledger cache.

Logs

2022-12-13 17:50:21.327 1 [error] emulator@Undefined:Undefined:Undefined Error in process <0.1719.0> on node 'miner@127.0.0.1' with exit value:
{function_clause,[{blockchain,ledger,[undefined],[{file,"blockchain.erl"},{line,556}]},{blockchain_worker,'-init/1-fun-4-',0,[{file,"blockchain_worker.erl"},{line,437}]}]}

Likely source

The likely source of the issue is this section of the blockchain_worker startup, which spawns a function that eventually attempts to instantiate a ledger, regardless of whether the app is following the chain:

    case application:get_env(blockchain, disable_prewarm, false) of
        true -> ok;
        false ->
            spawn(fun() ->
                          timer:sleep(90000),
                          Ledger = blockchain:ledger(),
                          blockchain_region_v1:prewarm_cache(Ledger)
                  end)
    end,

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions