From cba1a903041cf57e19944f88a64e6d4ef5a60cb0 Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Thu, 30 Aug 2018 18:25:47 +0100 Subject: Create shard files if missing If, when a database is created, it was not possible to create any of the shard files, the database cannot be used. All requests return a "No DB shards could be opened." error. This commit changes fabric_util:get_db/2 to create the shard file if missing. This is correct as that function has already called mem3:shards(DbName) which only returns shards if the database exists. --- src/fabric/src/fabric_util.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fabric/src/fabric_util.erl b/src/fabric/src/fabric_util.erl index dd4b80da6..e622c6aa0 100644 --- a/src/fabric/src/fabric_util.erl +++ b/src/fabric/src/fabric_util.erl @@ -179,7 +179,7 @@ get_db(DbName, Options) -> Nodes = [node()|erlang:nodes()], Live = [S || #shard{node = N} = S <- Shards, lists:member(N, Nodes)], Factor = list_to_integer(config:get("fabric", "shard_timeout_factor", "2")), - get_shard(Live, Options, 100, Factor). + get_shard(Live, [{create_if_missing, true} | Options], 100, Factor). get_shard([], _Opts, _Timeout, _Factor) -> erlang:error({internal_server_error, "No DB shards could be opened."}); -- cgit v1.2.1