This is an automated email from the ASF dual-hosted git repository. vatamane pushed a commit to branch remove-test-only-function in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 3b9f4766cab23b3c8b8bcc6e65b43533cee3f003 Author: Nick Vatamaniuc <[email protected]> AuthorDate: Thu Jan 22 13:17:25 2026 -0500 Remove mem3_util:update_db_doc/1 function It's used in a single test only. Use `mem3:update_db_doc/1` in the test and remove the mem3_util one. --- src/mem3/src/mem3_util.erl | 33 +------------------------------- src/mem3/test/eunit/mem3_shards_test.erl | 5 +---- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/src/mem3/src/mem3_util.erl b/src/mem3/src/mem3_util.erl index f45ee4063..cc728e0ee 100644 --- a/src/mem3/src/mem3_util.erl +++ b/src/mem3/src/mem3_util.erl @@ -24,8 +24,7 @@ delete_db_doc/1, shard_info/1, ensure_exists/1, - open_db_doc/1, - update_db_doc/1 + open_db_doc/1 ]). -export([get_or_create_db/2, get_or_create_db_int/2]). -export([is_deleted/1, rotate_list/2]). @@ -134,36 +133,6 @@ write_db_doc(DbName, #doc{id = Id, body = Body} = Doc, ShouldMutate) -> couch_db:close(Db) end. -update_db_doc(Doc) -> - update_db_doc(mem3_sync:shards_db(), Doc, true). - -update_db_doc(DbName, #doc{id = Id, body = Body} = Doc, ShouldMutate) -> - ioq:maybe_set_io_priority({system, DbName}), - {ok, Db} = couch_db:open(DbName, [?ADMIN_CTX]), - try couch_db:open_doc(Db, Id, [ejson_body]) of - {ok, #doc{body = Body}} -> - % the doc is already in the desired state, we're done here - ok; - {ok, #doc{body = Body1}} -> - % the doc has a new body to be written - {ok, _} = couch_db:update_doc(Db, Doc#doc{body = Body1}, []), - ok; - {not_found, _} when ShouldMutate -> - try couch_db:update_doc(Db, Doc, []) of - {ok, _} -> - ok - catch - conflict -> - % check to see if this was a replication race or a different edit - update_db_doc(DbName, Doc, false) - end; - _ -> - % the doc already exists in a different state - conflict - after - couch_db:close(Db) - end. - -spec range_to_hex([non_neg_integer()]) -> binary(). range_to_hex([B, E]) when is_integer(B), is_integer(E) -> HexB = couch_util:to_hex(<<B:32/integer>>), diff --git a/src/mem3/test/eunit/mem3_shards_test.erl b/src/mem3/test/eunit/mem3_shards_test.erl index c853dc4d0..a42296f2e 100644 --- a/src/mem3/test/eunit/mem3_shards_test.erl +++ b/src/mem3/test/eunit/mem3_shards_test.erl @@ -15,10 +15,7 @@ -include_lib("couch/include/couch_eunit.hrl"). -include_lib("couch/include/couch_db.hrl"). -include_lib("mem3/src/mem3_reshard.hrl"). -% for all_docs function --include_lib("couch_mrview/include/couch_mrview.hrl"). --define(ID, <<"_id">>). -define(TIMEOUT, 60). setup() -> @@ -69,7 +66,7 @@ partitioned_shards_recreated_properly(#{dbname := DbName, dbdoc := DbDoc}) -> ?assert(is_partitioned(Shards)), ok = with_proc(fun() -> couch_server:delete(ShardName, []) end), ?assertThrow({not_found, no_db_file}, is_partitioned(Shard)), - ok = mem3_util:update_db_doc(DbDoc#doc{body = {Body1}}), + {ok, {2, _Rev}} = mem3:update_db_doc(DbDoc#doc{body = {Body1}}), Shards = [Shard | _] = test_util:wait_value( fun() ->
