You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2020/02/24 23:02:00 UTC
[couchdb] 02/03: Fix bug in fdb_to_revinfo compatibility clauses
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ae4abe8f2b6dd23771ca1412caf2e53b1763990c
Author: Jay Doane <ja...@apache.org>
AuthorDate: Thu Feb 20 01:41:33 2020 -0800
Fix bug in fdb_to_revinfo compatibility clauses
A bug was introduced in https://github.com/apache/couchdb/commit/eb1a09e114dafc55fa9511d477b9ada4350134eb#diff-32274bcb4785f432811085d2e08c3580L1227
when `CURR_REV_FORMAT` was bumped from `1->2`, but `?CURR_REV_FORMAT` in
compatibility clauses going from format version `0->1` were left
unchanged, when those values of `?CURR_REV_FORMAT` should have changed
to `1`.
This fixes the compatibility clauses for rev format versions from `0->1`
---
src/fabric/src/fabric2_fdb.erl | 32 +++++---------------------
src/fabric/test/fabric2_db_misc_tests.erl | 37 -------------------------------
2 files changed, 5 insertions(+), 64 deletions(-)
diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index c181225..ed4371a 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -38,8 +38,6 @@
incr_stat/3,
incr_stat/4,
- fdb_to_revinfo/2,
-
get_all_revs/2,
get_winning_revs/3,
get_winning_revs_future/3,
@@ -1255,21 +1253,6 @@ fdb_to_revinfo(Key, {?CURR_REV_FORMAT, _, _, _, _, _} = Val) ->
rev_size => RevSize
};
-fdb_to_revinfo(Key, {?CURR_REV_FORMAT, _, _, _, _} = Val) ->
- {?DB_REVS, _DocId, NotDeleted, RevPos, Rev} = Key,
- {_RevFormat, Sequence, RevSize, RevPath, AttHash} = Val,
- #{
- winner => true,
- exists => true,
- deleted => not NotDeleted,
- rev_id => {RevPos, Rev},
- rev_path => tuple_to_list(RevPath),
- sequence => Sequence,
- branch_count => undefined,
- att_hash => AttHash,
- rev_size => RevSize
- };
-
fdb_to_revinfo(Key, {?CURR_REV_FORMAT, _, _, _} = Val) ->
{?DB_REVS, _DocId, NotDeleted, RevPos, Rev} = Key,
{_RevFormat, RevPath, AttHash, RevSize} = Val,
@@ -1286,27 +1269,22 @@ fdb_to_revinfo(Key, {?CURR_REV_FORMAT, _, _, _} = Val) ->
};
fdb_to_revinfo(Key, {0, Seq, BCount, RPath}) ->
- Val = {?CURR_REV_FORMAT, Seq, BCount, RPath, <<>>},
+ Val = {1, Seq, BCount, RPath, <<>>},
fdb_to_revinfo(Key, Val);
fdb_to_revinfo(Key, {0, RPath}) ->
- Val = {?CURR_REV_FORMAT, RPath, <<>>},
+ Val = {1, RPath, <<>>},
fdb_to_revinfo(Key, Val);
fdb_to_revinfo(Key, {1, Seq, BCount, RPath, AttHash}) ->
+ % Don't forget to change ?CURR_REV_FORMAT to 2 here when it increments
Val = {?CURR_REV_FORMAT, Seq, BCount, RPath, AttHash, 0},
fdb_to_revinfo(Key, Val);
fdb_to_revinfo(Key, {1, RPath, AttHash}) ->
+ % Don't forget to change ?CURR_REV_FORMAT to 2 here when it increments
Val = {?CURR_REV_FORMAT, RPath, AttHash, 0},
- fdb_to_revinfo(Key, Val);
-
-fdb_to_revinfo(Key, Val) ->
- couch_log:error(
- "~p:fdb_to_revinfo unsupported val format "
- "rev_format=~p key_size=~p val_size=~p",
- [?MODULE, element(1, Val), tuple_size(Key), tuple_size(Val)]),
- throw({unsupported_data_format, fdb_to_revinfo_val}).
+ fdb_to_revinfo(Key, Val).
doc_to_fdb(Db, #doc{} = Doc) ->
diff --git a/src/fabric/test/fabric2_db_misc_tests.erl b/src/fabric/test/fabric2_db_misc_tests.erl
index 7c88b4a..42a63e2 100644
--- a/src/fabric/test/fabric2_db_misc_tests.erl
+++ b/src/fabric/test/fabric2_db_misc_tests.erl
@@ -333,40 +333,3 @@ db_version_bump({DbName, _, _}) ->
% Check that db handle in the cache got the new metadata version
?assertMatch(#{db_version := NewDbVersion}, Db2).
-
-
-fdb_to_revinfo_test_() ->
- {
- "Test fdb_to_revinfo compatibility",
- {
- setup,
- fun() -> ok end,
- fun(_) -> ok end,
- with([
- ?TDEF(fdb_to_revinfo)
- ])
- }
- }.
-
-
-fdb_to_revinfo(_) ->
- Sequence = {versionstamp, 10873034897377, 0, 0},
- Rev = <<60,84,174,140,210,120,192,18,100,148,9,181,129,165,248,92>>,
- Key = {20, <<"d491280e-feab-42ce-909e-a7287d7b078-bluemix">>, true, 1, Rev},
- FiveTupleVal = {2, Sequence, 1, {}, <<>>},
- Expect = #{
- att_hash => <<>>,
- branch_count => undefined,
- deleted => false,
- exists => true,
- rev_id =>
- {1, <<60,84,174,140,210,120,192,18,100,148,9,181,129,165,248,92>>},
- rev_path => [],
- rev_size => 1,
- sequence => Sequence,
- winner => true
- },
- ?assertEqual(Expect, fabric2_fdb:fdb_to_revinfo(Key, FiveTupleVal)),
- ?assertThrow({unsupported_data_format, fdb_to_revinfo_val},
- fabric2_fdb:fdb_to_revinfo({bad}, {input})),
- ok.