davisp commented on a change in pull request #3127:
URL: https://github.com/apache/couchdb/pull/3127#discussion_r485073562
##########
File path: src/couch_views/src/couch_views_indexer.erl
##########
@@ -165,48 +171,60 @@ add_error(Error, Reason, Data) ->
update(#{} = Db, Mrst0, State0) ->
- Limiter = maps:get(limiter, State0),
- case couch_rate:budget(Limiter) of
- 0 ->
- couch_rate:wait(Limiter),
- update(Db, Mrst0, State0);
- Limit ->
- {Mrst1, State1} = do_update(Db, Mrst0, State0#{limit => Limit,
limiter => Limiter}),
- case State1 of
- finished ->
- couch_eval:release_map_context(Mrst1#mrst.qserver);
- _ ->
- couch_rate:wait(Limiter),
- update(Db, Mrst1, State1)
+ Limit = couch_views_batch:start(),
+ try
+ {Mrst1, State1} = do_update(Db, Mrst0, State0#{limit => Limit}),
+ case State1 of
+ finished ->
+ couch_eval:release_map_context(Mrst1#mrst.qserver);
+ _ ->
+ #{
+ docs_read := DocsRead,
+ tx_size := TxSize
+ } = State1,
+ couch_views_batch:success(TxSize, DocsRead),
+ update(Db, Mrst1, State1)
+ end
+ catch
+ error:{erlfdb_error, Error} ->
+ case lists:member(Error, ?RETRY_FAILURES) of
+ true ->
+ couch_views_batch:failure(),
+ update(Db, Mrst0, State0);
+ false ->
+ erlang:error({erlfdb_error, Error})
Review comment:
That seems reasonable. I'll update to use that pattern.
----------------------------------------------------------------
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:
[email protected]