couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r678923 - in /incubator/couchdb/trunk: share/www/script/couch_tests.js src/couchdb/couch_db.erl
Date Tue, 22 Jul 2008 22:04:58 GMT
Author: damien
Date: Tue Jul 22 15:04:58 2008
New Revision: 678923

URL: http://svn.apache.org/viewvc?rev=678923&view=rev
Log:
Fix for compacted databases reporting 0 documents after compaction

Modified:
    incubator/couchdb/trunk/share/www/script/couch_tests.js
    incubator/couchdb/trunk/src/couchdb/couch_db.erl

Modified: incubator/couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch_tests.js?rev=678923&r1=678922&r2=678923&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] Tue Jul 22 15:04:58 2008
@@ -1331,14 +1331,13 @@
     T(xhr.status == 202);
     // compaction isn't instantaneous, loop until done
     while (db.info().compact_running) {};
-
+    
+    restartServer();
     var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt");
     T(xhr.responseText == "This is a base64 encoded text")
     T(xhr.getResponseHeader("Content-Type") == "text/plain")
-
-    var compactedsize = db.info().disk_size;
-
-    T(compactedsize < deletesize);
+    T(db.info().doc_count == 1);
+    T(db.info().disk_size < deletesize);
   }
 };
 

Modified: incubator/couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_db.erl?rev=678923&r1=678922&r2=678923&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_db.erl Tue Jul 22 15:04:58 2008
@@ -568,16 +568,17 @@
                 init_db(Name, CompactFilepath, NewFd, NewHeader),
         case Db#db.update_seq == NewSeq of
         true ->
+            NewDb2 = commit_data(
+                NewDb#db{
+                    main_pid = Db#db.main_pid,
+                    doc_count = Db#db.doc_count,
+                    doc_del_count = Db#db.doc_del_count,
+                    filepath = Filepath}),
+                
             ?LOG_DEBUG("CouchDB swapping files ~s and ~s.", [Filepath, CompactFilepath]),
             ok = file:rename(Filepath, Filepath ++ ".old"),
             ok = file:rename(CompactFilepath, Filepath),
             
-            NewDb2 = NewDb#db{
-                main_pid = Db#db.main_pid,
-                doc_count = Db#db.doc_count,
-                doc_del_count = Db#db.doc_del_count,
-                filepath = Filepath},
-            
             couch_stream:close(Db#db.summary_stream),
             % close file handle async.
             % wait 5 secs before closing, allowing readers to finish



Mime
View raw message