You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2011/01/12 05:50:49 UTC
svn commit: r1057987 - in /couchdb/branches/1.1.x: THANKS
share/www/script/test/purge.js src/couchdb/couch_db_updater.erl
Author: kocolosk
Date: Wed Jan 12 04:50:48 2011
New Revision: 1057987
URL: http://svn.apache.org/viewvc?rev=1057987&view=rev
Log:
Preserve purge metadata during compaction, thanks Mike Leddy
Closes COUCHDB-1021
Modified:
couchdb/branches/1.1.x/THANKS
couchdb/branches/1.1.x/share/www/script/test/purge.js
couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl
Modified: couchdb/branches/1.1.x/THANKS
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/THANKS?rev=1057987&r1=1057986&r2=1057987&view=diff
==============================================================================
--- couchdb/branches/1.1.x/THANKS (original)
+++ couchdb/branches/1.1.x/THANKS Wed Jan 12 04:50:48 2011
@@ -74,5 +74,6 @@ suggesting improvements or submitting ch
* Jeff Zellner <je...@gmail.com>
* Benjamin Young <by...@bigbluehat.com>
* Gabriel Farrell <gs...@gmail.com>
+ * Mike Leddy <mi...@loop.com.br>
For a list of authors see the `AUTHORS` file.
Modified: couchdb/branches/1.1.x/share/www/script/test/purge.js
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/share/www/script/test/purge.js?rev=1057987&r1=1057986&r2=1057987&view=diff
==============================================================================
--- couchdb/branches/1.1.x/share/www/script/test/purge.js (original)
+++ couchdb/branches/1.1.x/share/www/script/test/purge.js Wed Jan 12 04:50:48 2011
@@ -76,6 +76,14 @@ couchTests.purge = function(debug) {
}
T(db.view("test/single_doc").total_rows == 0);
+ // purge sequences are preserved after compaction (COUCHDB-1021)
+ T(db.compact().ok);
+ T(db.last_req.status == 202);
+ // compaction isn't instantaneous, loop until done
+ while (db.info().compact_running) {};
+ var compactInfo = db.info();
+ T(compactInfo.purge_seq == newInfo.purge_seq);
+
// purge documents twice in a row without loading views
// (causes full view rebuilds)
Modified: couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl?rev=1057987&r1=1057986&r2=1057987&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl Wed Jan 12 04:50:48 2011
@@ -847,7 +847,7 @@ copy_compact(Db, NewDb0, Retry) ->
commit_data(NewDb4#db{update_seq=Db#db.update_seq}).
-start_copy_compact(#db{name=Name,filepath=Filepath}=Db) ->
+start_copy_compact(#db{name=Name,filepath=Filepath,header=#db_header{purge_seq=PurgeSeq}}=Db) ->
CompactFile = Filepath ++ ".compact",
?LOG_DEBUG("Compaction process spawned for db \"~s\"", [Name]),
case couch_file:open(CompactFile) of
@@ -867,8 +867,16 @@ start_copy_compact(#db{name=Name,filepat
ok = couch_file:write_header(Fd, Header=#db_header{})
end,
NewDb = init_db(Name, CompactFile, Fd, Header),
+ NewDb2 = if PurgeSeq > 0 ->
+ {ok, PurgedIdsRevs} = couch_db:get_last_purged(Db),
+ {ok, Pointer} = couch_file:append_term(Fd, PurgedIdsRevs),
+ NewDb#db{header=Header#db_header{purge_seq=PurgeSeq, purged_docs=Pointer}};
+ true ->
+ NewDb
+ end,
unlink(Fd),
- NewDb2 = copy_compact(Db, NewDb, Retry),
- close_db(NewDb2),
+
+ NewDb3 = copy_compact(Db, NewDb2, Retry),
+ close_db(NewDb3),
gen_server:cast(Db#db.update_pid, {compact_done, CompactFile}).