You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/05/05 16:35:07 UTC

[GitHub] [couchdb] davisp commented on a change in pull request #2869: fetch local docs in fold_docs function

davisp commented on a change in pull request #2869:
URL: https://github.com/apache/couchdb/pull/2869#discussion_r420246021



##########
File path: src/fabric/src/fabric2_db.erl
##########
@@ -996,17 +996,32 @@ fold_docs(Db, DocIds, UserFun, UserAcc0, Options) ->
                 user_fun => UserFun
             },
 
-            FinalAcc1 = lists:foldl(fun(DocId, Acc) ->
-                #{
-                    revs_q := RevsQ,
-                    revs_count := RevsCount
-                } = Acc,
-                Future = FetchRevs(DocId),
-                NewAcc = Acc#{
-                    revs_q := queue:in({DocId, Future}, RevsQ),
-                    revs_count := RevsCount + 1
-                },
-                drain_fold_docs_revs_futures(TxDb, NewAcc)
+            FinalAcc1 = lists:foldl(fun
+                (<<?LOCAL_DOC_PREFIX, _/binary>> = DocId, Acc) ->
+                    DocResp = case fabric2_fdb:get_local_doc(TxDb, DocId) of
+                        #doc{} = Doc -> {ok, Doc};
+                        _Else -> {not_found, missing}
+                    end,
+                    #{
+                        user_acc := UserAcc,
+                        user_fun := UserFun
+                    } = Acc,
+
+                    NewUserAcc = maybe_stop(UserFun(DocId, DocResp, UserAcc)),

Review comment:
       This is broken. You can't mix synchronous and asynchronous fetches like this. `POST /dbname/_all_docs` has a (perhaps implicit?) contract for returning docs in the order specified in the body. Mixing these operations means that we'd be returning any `_local` docs in some random position within the previous 100 or so docs returned.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org