couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tonysu...@apache.org
Subject [couchdb] 01/01: add compaction logging
Date Tue, 30 May 2017 16:25:55 GMT
This is an automated email from the ASF dual-hosted git repository.

tonysun83 pushed a commit to branch 3417-add-compaction-logging
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d6d53acc2f9552b7357d328f8bedf8d3ce9849af
Author: Tony Sun <tony.sun@cloudant.com>
AuthorDate: Wed May 10 21:16:13 2017 -0700

    add compaction logging
    
    To predict future compaction results, we log pre-compaction and
    post-compaction file sizes. These log results will be used as data
    points for regression analysis.
    
    COUCHDB-3417
---
 src/couch/src/couch_db_updater.erl              |  9 ++++++---
 src/couch_mrview/src/couch_mrview_compactor.erl | 11 ++++++++++-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/couch/src/couch_db_updater.erl b/src/couch/src/couch_db_updater.erl
index 7872635..bb8e9da 100644
--- a/src/couch/src/couch_db_updater.erl
+++ b/src/couch/src/couch_db_updater.erl
@@ -218,7 +218,7 @@ handle_cast(start_compact, Db) ->
         % compact currently running, this is a no-op
         {noreply, Db}
     end;
-handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) ->
+handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath,fd=Fd}=Db) ->
     {ok, NewFd} = couch_file:open(CompactFilepath),
     {ok, NewHeader0} = couch_file:read_header(NewFd),
     NewHeader = couch_db_header:set(NewHeader0, [
@@ -242,8 +242,11 @@ handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db)
->
             revs_limit = Db#db.revs_limit
         }),
 
-        couch_log:debug("CouchDB swapping files ~s and ~s.",
-                        [Filepath, CompactFilepath]),
+        {ok, Pre} = couch_file:bytes(Fd),
+        {ok, Post} = couch_file:bytes(NewFd),
+
+        couch_log:notice("Compaction swap for db: ~s ~p ~p", [Filepath,
+                Pre, Post]),
         ok = file:rename(CompactFilepath, Filepath ++ ".compact"),
         RootDir = config:get("couchdb", "database_dir", "."),
         couch_file:delete(RootDir, Filepath),
diff --git a/src/couch_mrview/src/couch_mrview_compactor.erl b/src/couch_mrview/src/couch_mrview_compactor.erl
index fabe289..c1b2fbc 100644
--- a/src/couch_mrview/src/couch_mrview_compactor.erl
+++ b/src/couch_mrview/src/couch_mrview_compactor.erl
@@ -275,8 +275,12 @@ update_task(VID, #acc{changes=Changes, total_changes=Total}=Acc, ChangesInc)
->
 
 swap_compacted(OldState, NewState) ->
     #mrst{
+        fd = Fd
+    } = OldState,
+    #mrst{
         sig=Sig,
-        db_name=DbName
+        db_name=DbName,
+        fd=NewFd
     } = NewState,
 
     link(NewState#mrst.fd),
@@ -285,6 +289,11 @@ swap_compacted(OldState, NewState) ->
     RootDir = couch_index_util:root_dir(),
     IndexFName = couch_mrview_util:index_file(DbName, Sig),
     CompactFName = couch_mrview_util:compaction_file(DbName, Sig),
+
+    {ok, Pre} = couch_file:bytes(Fd),
+    {ok, Post} = couch_file:bytes(NewFd),
+    couch_log:notice("Compaction swap for view ~s ~p ~p", [IndexFName,
+        Pre, Post]),
     ok = couch_file:delete(RootDir, IndexFName),
     ok = file:rename(CompactFName, IndexFName),
 

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <commits@couchdb.apache.org>.

Mime
View raw message