diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl index 875df6e0005..ff2203af88f 100644 --- a/src/chttpd/src/chttpd_db.erl +++ b/src/chttpd/src/chttpd_db.erl @@ -554,12 +554,13 @@ db_req( %% for missing databases that'd return error 404 from chttpd %% get_security used to prefer shards on the same node over other nodes fabric:get_security(DbName, [{user_ctx, Ctx}]), + #shard{suffix = Suffix} = hd(mem3:shards(DbName)), send_json( Req, 201, {[ {ok, true}, - {instance_start_time, <<"0">>} + {instance_start_time, Suffix} ]} ); db_req(#httpd{path_parts = [_, <<"_ensure_full_commit">>]} = Req, _Db) -> diff --git a/src/fabric/src/fabric_db_info.erl b/src/fabric/src/fabric_db_info.erl index 2366420c894..1f499587272 100644 --- a/src/fabric/src/fabric_db_info.erl +++ b/src/fabric/src/fabric_db_info.erl @@ -19,6 +19,7 @@ go(DbName) -> Shards = mem3:shards(DbName), + #shard{suffix = Suffix} = hd(mem3:shards(DbName)), Workers = fabric_util:submit_jobs(Shards, get_db_info, []), RexiMon = fabric_util:create_monitors(Shards), Fun = fun handle_message/3, @@ -28,7 +29,7 @@ go(DbName) -> try case fabric_util:recv(Workers, #shard.ref, Fun, Acc0) of {ok, Acc} -> - {ok, Acc}; + {ok, [{instance_start_time, Suffix} | Acc]}; {timeout, {WorkersDict, _, _}} -> DefunctWorkers = fabric_util:remove_done_workers( WorkersDict, @@ -117,7 +118,7 @@ merge_results(Info) -> (_K, _V, Acc) -> Acc end, - [{instance_start_time, <<"0">>}], + [], Dict ). diff --git a/src/mem3/include/mem3.hrl b/src/mem3/include/mem3.hrl index d97b2546962..97dbca5785c 100644 --- a/src/mem3/include/mem3.hrl +++ b/src/mem3/include/mem3.hrl @@ -22,6 +22,7 @@ dbname :: binary() | 'undefined', range :: [non_neg_integer() | '$1' | '$2'] | '_' | 'undefined', ref :: reference() | '_' | 'undefined', + suffix :: binary(), opts :: list() | 'undefined' }). @@ -33,6 +34,7 @@ range :: [non_neg_integer() | '$1' | '$2'] | '_', ref :: reference() | 'undefined' | '_', order :: non_neg_integer() | 'undefined' | '_', + suffix :: binary(), opts :: list() }). diff --git a/src/mem3/src/mem3_util.erl b/src/mem3/src/mem3_util.erl index 8547fc071d4..b39d365e821 100644 --- a/src/mem3/src/mem3_util.erl +++ b/src/mem3/src/mem3_util.erl @@ -228,6 +228,7 @@ build_shards_by_node(DbName, DocProps) -> dbname = DbName, node = to_atom(Node), range = [Beg, End], + suffix = list_to_binary(Suffix), opts = get_shard_opts(DocProps) }, Suffix @@ -255,6 +256,7 @@ build_shards_by_range(DbName, DocProps) -> node = to_atom(Node), range = [Beg, End], order = Order, + suffix = list_to_binary(Suffix), opts = get_shard_opts(DocProps) }, Suffix @@ -370,6 +372,7 @@ downcast(#ordered_shard{} = S) -> dbname = S#ordered_shard.dbname, range = S#ordered_shard.range, ref = S#ordered_shard.ref, + suffix = S#ordered_shard.suffix, opts = S#ordered_shard.opts }; downcast(Shards) when is_list(Shards) -> diff --git a/src/mem3/test/eunit/mem3_util_test.erl b/src/mem3/test/eunit/mem3_util_test.erl index 9cab89f6706..4fdf49dc4a0 100644 --- a/src/mem3/test/eunit/mem3_util_test.erl +++ b/src/mem3/test/eunit/mem3_util_test.erl @@ -113,21 +113,21 @@ build_shards_test() -> ExpectedShards1 = [ {shard, <<"shards/00000000-1fffffff/testdb1">>, 'bigcouch@node.local', <<"testdb1">>, - [0, 536870911], undefined, []}, + [0, 536870911], undefined, <<>>, []}, {shard, <<"shards/20000000-3fffffff/testdb1">>, 'bigcouch@node.local', <<"testdb1">>, - [536870912, 1073741823], undefined, []}, + [536870912, 1073741823], undefined, <<>>, []}, {shard, <<"shards/40000000-5fffffff/testdb1">>, 'bigcouch@node.local', <<"testdb1">>, - [1073741824, 1610612735], undefined, []}, + [1073741824, 1610612735], undefined, <<>>, []}, {shard, <<"shards/60000000-7fffffff/testdb1">>, 'bigcouch@node.local', <<"testdb1">>, - [1610612736, 2147483647], undefined, []}, + [1610612736, 2147483647], undefined, <<>>, []}, {shard, <<"shards/80000000-9fffffff/testdb1">>, 'bigcouch@node.local', <<"testdb1">>, - [2147483648, 2684354559], undefined, []}, + [2147483648, 2684354559], undefined, <<>>, []}, {shard, <<"shards/a0000000-bfffffff/testdb1">>, 'bigcouch@node.local', <<"testdb1">>, - [2684354560, 3221225471], undefined, []}, + [2684354560, 3221225471], undefined, <<>>, []}, {shard, <<"shards/c0000000-dfffffff/testdb1">>, 'bigcouch@node.local', <<"testdb1">>, - [3221225472, 3758096383], undefined, []}, + [3221225472, 3758096383], undefined, <<>>, []}, {shard, <<"shards/e0000000-ffffffff/testdb1">>, 'bigcouch@node.local', <<"testdb1">>, - [3758096384, 4294967295], undefined, []} + [3758096384, 4294967295], undefined, <<>>, []} ], ?assertEqual(ExpectedShards1, Shards1), ok.