davisp commented on a change in pull request #754: Compactor optimization - PR FOR FEEDBACK ONLY URL: https://github.com/apache/couchdb/pull/754#discussion_r133548905
########## File path: src/couch/src/couch_db_updater.erl ########## @@ -1034,56 +1041,90 @@ check_md5(_, _) -> throw(md5_mismatch). start_copy_compact(#db{}=Db) -> erlang:put(io_priority, {db_compact, Db#db.name}), - #db{name=Name, filepath=Filepath, options=Options, header=Header} = Db, - couch_log:debug("Compaction process spawned for db \"~s\"", [Name]), + couch_log:debug("Compaction process spawned for db \"~s\"", [Db#db.name]), + + {ok, InitCompSt} = open_compaction_files(Db), + + Stages = [ + fun copy_purge_info/1, + fun copy_compact/1, + fun commit_compaction_data/1, + fun sort_meta_data/1, + fun commit_compaction_data/1, + fun copy_meta_data/1, + fun compact_final_sync/1 + ], - {ok, NewDb, DName, DFd, MFd, Retry} = - open_compaction_files(Name, Header, Filepath, Options), - erlang:monitor(process, MFd), + FinalCompSt = lists:foldl(fun(Stage, CompSt) -> + Stage(CompSt) + end, InitCompSt, Stages), - % This is a bit worrisome. init_db/4 will monitor the data fd - % but it doesn't know about the meta fd. For now I'll maintain - % that the data fd is the old normal fd and meta fd is special - % and hope everything works out for the best. Review comment: Yep, it got moved to clean up start_compact. That comment is way old me. I know how couch_file works better now so the comment can go as its misleading. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services