You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2021/02/26 19:12:05 UTC
[couchdb] branch fix-view-row-bug created (now 2a66a03)
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a change to branch fix-view-row-bug
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
at 2a66a03 Fix ebtree:lookup_multi/3
This branch includes the following new commits:
new c9440e6 Fix typo
new dc7382f Add failing cases for ebtree:lookup_multi/3 bug
new 2a66a03 Fix ebtree:lookup_multi/3
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb] 03/03: Fix ebtree:lookup_multi/3
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch fix-view-row-bug
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 2a66a03eb55f88286f3a3c513271daeb34946b30
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Fri Feb 26 12:37:04 2021 -0600
Fix ebtree:lookup_multi/3
If one of the provided lookup keys doesn't exist in the ebtree, it can
inadvertently prevent a second lookup key from being found if it the
first key greater than the missing lookup key is equal to the second
lookup key.
---
src/ebtree/src/ebtree.erl | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/ebtree/src/ebtree.erl b/src/ebtree/src/ebtree.erl
index bbb0ca8..8c921d1 100644
--- a/src/ebtree/src/ebtree.erl
+++ b/src/ebtree/src/ebtree.erl
@@ -173,18 +173,17 @@ lookup_multi_fold(_, {_, [], _} = Acc) ->
{stop, Acc};
lookup_multi_fold({visit, Key1, Value}, {Tree, [Key2 | Rest], Acc}) ->
- {NewKeys, NewAcc} = case collate(Tree, Key1, Key2) of
+ case collate(Tree, Key1, Key2) of
lt ->
% Still looking for the next user key
- {[Key2 | Rest], Acc};
+ {ok, {Tree, [Key2 | Rest], Acc}};
eq ->
% Found a requested key
- {Rest, [{Key2, Value} | Acc]};
+ {ok, {Tree, Rest, [{Key2, Value} | Acc]}};
gt ->
% The user key wasn't found so we drop it
- {Rest, Acc}
- end,
- {ok, {Tree, NewKeys, NewAcc}};
+ lookup_multi_fold({visit, Key1, Value}, {Tree, Rest, Acc})
+ end;
lookup_multi_fold({traverse, FKey, LKey, R}, {Tree, [UKey | Rest], Acc}) ->
case collate(Tree, FKey, UKey, [gt]) of
[couchdb] 02/03: Add failing cases for ebtree:lookup_multi/3 bug
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch fix-view-row-bug
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit dc7382fa11a64fc4b63d19cc4ba95d313340d8a7
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Fri Feb 26 13:08:42 2021 -0600
Add failing cases for ebtree:lookup_multi/3 bug
These two test cases expose the subtle bug in ebtree:lookup_multi/3
where a key that doesn't exist in the tree can prevent a subsequent
lookup key from matching in the same KV node.
---
src/couch_views/test/couch_views_indexer_test.erl | 27 +++++++++++++++++++++++
src/ebtree/src/ebtree.erl | 3 ++-
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/couch_views/test/couch_views_indexer_test.erl b/src/couch_views/test/couch_views_indexer_test.erl
index e18c007..09493db 100644
--- a/src/couch_views/test/couch_views_indexer_test.erl
+++ b/src/couch_views/test/couch_views_indexer_test.erl
@@ -47,6 +47,7 @@ indexer_test_() ->
?TDEF_FE(multiple_identical_keys_from_same_doc),
?TDEF_FE(fewer_multiple_identical_keys_from_same_doc),
?TDEF_FE(multiple_design_docs),
+ ?TDEF_FE(multiple_doc_update_with_existing_rows),
?TDEF_FE(handle_size_key_limits),
?TDEF_FE(handle_size_value_limits),
?TDEF_FE(index_autoupdater_callback),
@@ -424,6 +425,32 @@ multiple_design_docs(Db) ->
?assertError({ddoc_deleted, _}, run_query(Db, DDoc2, ?MAP_FUN1)).
+multiple_doc_update_with_existing_rows(Db) ->
+ couch_log:error("START TEST", []),
+ DDoc = create_ddoc(),
+ Doc0 = doc(0),
+ Doc1 = doc(1),
+
+ {ok, _} = fabric2_db:update_doc(Db, DDoc, []),
+ {ok, {Pos, Rev}} = fabric2_db:update_doc(Db, Doc1, []),
+
+ {ok, Out1} = run_query(Db, DDoc, ?MAP_FUN1),
+
+ ?assertEqual([row(<<"1">>, 1, 1)], Out1),
+
+ Doc2 = Doc1#doc{
+ revs = {Pos, [Rev]},
+ body = {[{<<"val">>, 2}]}
+ },
+ {ok, _} = fabric2_db:update_docs(Db, [Doc0, Doc2], []),
+
+ {ok, Out2} = run_query(Db, DDoc, ?MAP_FUN1),
+
+ ?assertEqual([
+ row(<<"0">>, 0, 0),
+ row(<<"1">>, 2, 2)
+ ], Out2).
+
handle_db_recreated_when_running(Db) ->
DbName = fabric2_db:name(Db),
diff --git a/src/ebtree/src/ebtree.erl b/src/ebtree/src/ebtree.erl
index 1a65c9a..bbb0ca8 100644
--- a/src/ebtree/src/ebtree.erl
+++ b/src/ebtree/src/ebtree.erl
@@ -1394,7 +1394,8 @@ lookup_multi_test() ->
validate_tree(Db, Tree),
?assertEqual([{1, 2}], lookup_multi(Db, Tree, [1])),
?assertEqual([{15, 16}, {2, 3}], lookup_multi(Db, Tree, [2, 15])),
- ?assertEqual([{15, 16}, {4, 5}, {2, 3}], lookup_multi(Db, Tree, [2, 101, 15, 4, -3])).
+ ?assertEqual([{15, 16}, {4, 5}, {2, 3}], lookup_multi(Db, Tree, [2, 101, 15, 4, -3])),
+ ?assertEqual([{2, 3}], lookup_multi(Db, Tree, [1.5, 2])).
insert_multi_test() ->
[couchdb] 01/03: Fix typo
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch fix-view-row-bug
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit c9440e67ab57c8d3e583af46f143394d3221936e
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Fri Feb 26 12:45:19 2021 -0600
Fix typo
---
src/couch_views/test/couch_views_indexer_test.erl | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/couch_views/test/couch_views_indexer_test.erl b/src/couch_views/test/couch_views_indexer_test.erl
index a0890da..e18c007 100644
--- a/src/couch_views/test/couch_views_indexer_test.erl
+++ b/src/couch_views/test/couch_views_indexer_test.erl
@@ -42,10 +42,10 @@ indexer_test_() ->
?TDEF_FE(updated_docs_without_changes_are_reindexed),
?TDEF_FE(deleted_docs_not_indexed),
?TDEF_FE(deleted_docs_are_unindexed),
- ?TDEF_FE(multipe_docs_with_same_key),
- ?TDEF_FE(multipe_keys_from_same_doc),
- ?TDEF_FE(multipe_identical_keys_from_same_doc),
- ?TDEF_FE(fewer_multipe_identical_keys_from_same_doc),
+ ?TDEF_FE(multiple_docs_with_same_key),
+ ?TDEF_FE(multiple_keys_from_same_doc),
+ ?TDEF_FE(multiple_identical_keys_from_same_doc),
+ ?TDEF_FE(fewer_multiple_identical_keys_from_same_doc),
?TDEF_FE(multiple_design_docs),
?TDEF_FE(handle_size_key_limits),
?TDEF_FE(handle_size_value_limits),
@@ -216,7 +216,7 @@ deleted_docs_are_unindexed(Db) ->
end).
-multipe_docs_with_same_key(Db) ->
+multiple_docs_with_same_key(Db) ->
DDoc = create_ddoc(),
Doc1 = doc(0, 1),
Doc2 = doc(1, 1),
@@ -232,7 +232,7 @@ multipe_docs_with_same_key(Db) ->
], Out).
-multipe_keys_from_same_doc(Db) ->
+multiple_keys_from_same_doc(Db) ->
DDoc = create_ddoc(multi_emit_different),
Doc = doc(0, 1),
@@ -247,7 +247,7 @@ multipe_keys_from_same_doc(Db) ->
], Out).
-multipe_identical_keys_from_same_doc(Db) ->
+multiple_identical_keys_from_same_doc(Db) ->
DDoc = create_ddoc(multi_emit_same),
Doc = doc(0, 1),
@@ -262,7 +262,7 @@ multipe_identical_keys_from_same_doc(Db) ->
], Out).
-fewer_multipe_identical_keys_from_same_doc(Db) ->
+fewer_multiple_identical_keys_from_same_doc(Db) ->
DDoc = create_ddoc(multi_emit_same),
Doc0 = #doc{
id = <<"0">>,