summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Branca <chewbranca@apache.org>2020-03-26 10:05:59 -0700
committerRussell Branca <chewbranca@apache.org>2020-03-26 15:46:07 -0700
commit9c956676dad078016e7eb030187ce2d87738183c (patch)
tree26bf5e78c55b08afc084c84ac3acc2e7c83da23d
parent7c831f68d9049334a2e10a8a3f5d82ba214992e4 (diff)
downloadcouchdb-fix-create-db-options.tar.gz
Add mem3_util:find_dirty_shards functionfix-create-db-options
-rw-r--r--src/mem3/src/mem3_util.erl42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/mem3/src/mem3_util.erl b/src/mem3/src/mem3_util.erl
index a6ac3a865..28cb17778 100644
--- a/src/mem3/src/mem3_util.erl
+++ b/src/mem3/src/mem3_util.erl
@@ -17,6 +17,7 @@
shard_info/1, ensure_exists/1, open_db_doc/1, get_or_create_db/2]).
-export([is_deleted/1, rotate_list/2]).
-export([get_shard_opts/1, get_engine_opt/1, get_props_opt/1]).
+-export([get_shard_props/1, find_dirty_shards/0]).
-export([
iso8601_timestamp/0,
live_nodes/0,
@@ -535,6 +536,47 @@ merge_opts(New, Old) ->
end, Old, New).
+get_shard_props(ShardName) ->
+ case couch_db:open_int(ShardName, []) of
+ {ok, Db} ->
+ Props = case couch_db_engine:get_props(Db) of
+ undefined -> [];
+ Else -> Else
+ end,
+ %% We don't normally store the default engine name
+ EngineProps = case couch_db_engine:get_engine(Db) of
+ couch_bt_engine ->
+ [];
+ EngineName ->
+ [{engine, EngineName}]
+ end,
+ [{props, Props} | EngineProps];
+ {not_found, _} ->
+ not_found;
+ Else ->
+ Else
+ end.
+
+
+find_dirty_shards() ->
+ mem3_shards:fold(fun(#shard{node=Node, name=Name, opts=Opts}=Shard, Acc) ->
+ case Opts of
+ [] ->
+ Acc;
+ [{props, []}] ->
+ Acc;
+ _ ->
+ Props = rpc:call(Node, ?MODULE, get_shard_props, [Name]),
+ case Props =:= Opts of
+ true ->
+ Acc;
+ false ->
+ [{Shard, Props} | Acc]
+ end
+ end
+ end, []).
+
+
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").