Permalink
Browse files

Unfix view compaction progress reports

This reverts the compaction task status progress back to what exists on
1.2.x. The issue is that we use the number of documents in the database
instead of the number of docids in the union of all views (the number of
rows in the view's id btree). In this particular case the desire to have
seamless view upgrades outweighs fixing the relatively minor UI bug.

backport from couchdb 1.3.x branch
  • Loading branch information...
benoitc committed Feb 9, 2013
1 parent 380fcb4 commit a2b282868053e942552b8495273cb99cc6d5d80d
Showing with 9 additions and 10 deletions.
  1. +8 −4 apps/couch_mrview/src/couch_mrview_compactor.erl
  2. +1 −6 apps/couch_mrview/src/couch_mrview_util.erl
@@ -44,10 +44,15 @@ compact(State) ->
views=Views
} = State,
- EmptyState = couch_util:with_db(DbName, fun(Db) ->
+ {EmptyState, NumDocIds} = couch_util:with_db(DbName, fun(Db) ->
CompactFName = couch_mrview_util:compaction_file(DbName, Sig),
{ok, Fd} = couch_mrview_util:open_file(CompactFName),
- couch_mrview_util:reset_index(Db, Fd, State)
+ ESt = couch_mrview_util:reset_index(Db, Fd, State),
+
+ {ok, DbReduce} = couch_btree:full_reduce(Db#db.fulldocinfo_by_id_btree),
+ Count = element(1, DbReduce),
+
+ {ESt, Count}
end),
#mrst{
@@ -56,13 +61,12 @@ compact(State) ->
views = EmptyViews
} = EmptyState,
- {ok, Count} = couch_btree:full_reduce(IdBtree),
TotalChanges0 = lists:foldl(
fun(View, Acc) ->
{ok, Kvs} = couch_mrview_util:get_row_count(View),
Acc + Kvs
end,
- Count, Views),
+ NumDocIds, Views),
TotalChanges = case SeqIndexed of
@@ -216,12 +216,7 @@ init_state(Db, Fd, State, Header) ->
end,
ViewStates2 = lists:map(StateUpdate, ViewStates),
- IdReduce = fun
- (reduce, KVs) -> length(KVs);
- (rereduce, Reds) -> lists:sum(Reds)
- end,
-
- IdBtOpts = [{reduce, IdReduce}, {compression, couch_db:compression(Db)}],
+ IdBtOpts = [{compression, couch_db:compression(Db)}],
{ok, IdBtree} = couch_btree:open(IdBtreeState, Fd, IdBtOpts),
{ok, SeqBtree} = case SeqIndexed of

0 comments on commit a2b2828

Please sign in to comment.