Author: fdmanana
Date: Sat Sep 24 01:00:14 2011
New Revision: 1175090
URL: http://svn.apache.org/viewvc?rev=1175090&view=rev
Log:
Fix database compaction crash on retry
If the compaction is retried 2 or more times, there's a badmatch
when asserting that the number of changes processed equals the
number of total changes. This is due to the fact that the task
properties were not updated properly once a retry happens.
This is a backport of revision 1175089 from trunk.
Modified:
couchdb/branches/1.2.x/src/couchdb/couch_db_updater.erl
Modified: couchdb/branches/1.2.x/src/couchdb/couch_db_updater.erl
URL:
http://svn.apache.org/viewvc/couchdb/branches/1.2.x/src/couchdb/couch_db_updater.erl?rev=1175090&r1=1175089&r2=1175090&view=diff
==============================================================================
--- couchdb/branches/1.2.x/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/branches/1.2.x/src/couchdb/couch_db_updater.erl Sat Sep 24 01:00:14
2011
@@ -924,7 +924,12 @@ copy_compact(Db, NewDb0, Retry) ->
],
case Retry of
true ->
- couch_task_status:update([{retry, true}]);
+ couch_task_status:update([
+ {retry, true},
+ {progress, 0},
+ {changes_done, 0},
+ {total_changes, TotalChanges}
+ ]);
false ->
couch_task_status:add_task(TaskProps0),
couch_task_status:set_update_frequency(500)
@@ -936,7 +941,7 @@ copy_compact(Db, NewDb0, Retry) ->
[{start_key, NewDb#db.update_seq + 1}]),
NewDb3 = copy_docs(Db, NewDb2, lists:reverse(Uncopied), Retry),
- TotalChanges = (couch_task_status:get(changes_done) - NewDb#db.update_seq),
+ TotalChanges = couch_task_status:get(changes_done),
% copy misc header values
if NewDb3#db.security /= Db#db.security ->