summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vatamaniuc <vatamane@apache.org>2021-03-02 15:20:57 -0500
committerNick Vatamaniuc <nickva@users.noreply.github.com>2021-03-02 15:42:16 -0500
commitfac13a3ff0cfe6502dc424a9a129d7dd265290e4 (patch)
tree80d51669149d2f705149110e610f529de6eafbdb
parent04086e67161ef6facaee6a119afbfc0fbafacb45 (diff)
downloadcouchdb-fac13a3ff0cfe6502dc424a9a129d7dd265290e4.tar.gz
Fix badmatch in couch_views_indexer
Previously, when an erlfdb error occured and a recursive call to `update/3` was made, the result of that call was always matched against `{Mrst, State}`. However, in the case when the call had finalized and returned `couch_eval:release_map_context/1` response, the result would be `ok` which would blow with a badmatch error against `{Mrst, State}`.
-rw-r--r--src/couch_views/src/couch_views_indexer.erl10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/couch_views/src/couch_views_indexer.erl b/src/couch_views/src/couch_views_indexer.erl
index e3b2ad5bc..8019d9f6a 100644
--- a/src/couch_views/src/couch_views_indexer.erl
+++ b/src/couch_views/src/couch_views_indexer.erl
@@ -182,17 +182,19 @@ add_error(Error, Reason, Data) ->
update(#{} = Db, Mrst0, State0) ->
Limit = couch_views_batch:start(Mrst0),
- {Mrst1, State1} = try
+ Result = try
do_update(Db, Mrst0, State0#{limit => Limit})
catch
error:{erlfdb_error, Error} when ?IS_RECOVERABLE_ERROR(Error) ->
couch_views_batch:failure(Mrst0),
update(Db, Mrst0, State0)
end,
- case State1 of
- finished ->
+ case Result of
+ ok ->
+ ok; % Already finished and released map context
+ {Mrst1, finished} ->
couch_eval:release_map_context(Mrst1#mrst.qserver);
- _ ->
+ {Mrst1, State1} ->
#{
update_stats := UpdateStats
} = State1,