From b445a6d4ce554cfde0dad5a99cd01e076824d021 Mon Sep 17 00:00:00 2001 From: Andrei Zavada Date: Mon, 21 Jun 2021 16:55:49 +0300 Subject: [PATCH] try code:load_file if loading with code:ensure_loaded fails ensure_loaded fails if our code server is in embedded mode. --- src/riak_kv_app.erl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/riak_kv_app.erl b/src/riak_kv_app.erl index cc1d0c7734..ab59d7b101 100644 --- a/src/riak_kv_app.erl +++ b/src/riak_kv_app.erl @@ -126,11 +126,20 @@ start(_Type, _StartArgs) -> %% Check the storage backend StorageBackend = app_helper:get_env(riak_kv, storage_backend), case code:ensure_loaded(StorageBackend) of - {error,nofile} -> - lager:critical("storage_backend ~p is non-loadable.", - [StorageBackend]), + {error, embedded} -> + case code:load_file(StorageBackend) of + {error, LoadReason} -> + lager:critical("storage_backend ~p is non-loadable: ~p.", + [StorageBackend, LoadReason]), + throw({error, invalid_storage_backend}); + {module, _} -> + ok + end; + {error, EnsureReason} -> + lager:critical("storage_backend ~p is non-loadable: ~p.", + [StorageBackend, EnsureReason]), throw({error, invalid_storage_backend}); - _ -> + {module, _} -> ok end,