Skip to content

Instantly share code, notes, and snippets.

diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index f087970..deba810 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -175,7 +175,7 @@ handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) ->
NewDb2 = commit_data(NewDb#db{
local_docs_btree = NewLocalBtree,
main_pid = Db#db.main_pid,
- filepath = Filepath,
+ filepath = CompactFilepath,
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index f087970..f68f756 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -698,11 +698,11 @@ commit_data(Db, _) ->
fsync_options = FsyncOptions,
waiting_delayed_commit = Timer
} = Db,
- if is_reference(Timer) -> erlang:cancel_timer(Timer); true -> ok end,
case db_to_header(Db, OldHeader) of
From becdc414824a787c267e608689bf4cfc8e608be2 Mon Sep 17 00:00:00 2001
From: Randall Leeds <randall.leeds@gmail.com>
Date: Thu, 12 Aug 2010 18:22:31 -0700
Subject: [PATCH] a reader queue makes couch_file fair to writers
---
src/couchdb/couch_db_updater.erl | 1 +
src/couchdb/couch_file.erl | 32 ++++++++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl
index 57b3008..301facb 100644
--- a/src/couchdb/couch_rep.erl
+++ b/src/couchdb/couch_rep.erl
@@ -648,7 +648,7 @@ do_checkpoint(State) ->
?LOG_INFO("recording a checkpoint for ~s -> ~s at source update_seq ~p",
[dbname(Source), dbname(Target), NewSeqNum]),
SessionId = couch_uuids:random(),
- NewHistoryEntry = {[
+ NewHistory = lists:sublist([{[
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index 7678f6c..df7c75b 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -645,7 +645,7 @@ update_docs(Db, Docs, Options, replicated_changes) ->
DocErrors = [],
DocBuckets3 = DocBuckets
end,
- DocBuckets4 = [[doc_flush_atts(check_dup_atts(Doc), Db#db.fd)
+ DocBuckets4 = [[check_dup_atts(Doc)
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index 19a4c16..6099d0a 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -439,15 +439,42 @@ refresh_validate_doc_funs(Db) ->
% rev tree functions
-flush_trees(_Db, [], AccFlushedTrees) ->
- {ok, lists:reverse(AccFlushedTrees)};
diff --git a/src/couchdb/couch_btree.erl b/src/couchdb/couch_btree.erl
index 0e47bac..ce7c4e1 100644
--- a/src/couchdb/couch_btree.erl
+++ b/src/couchdb/couch_btree.erl
@@ -186,10 +186,15 @@ query_modify(Bt, LookupKeys, InsertValues, RemoveKeys) ->
less(Bt, A, B)
end
end,
- Actions = lists:sort(SortFun, lists:append([InsertActions, RemoveActions, FetchActions])),
- {ok, KeyPointers, QueryResults, Bt2} = modify_node(Bt, Root, Actions, []),
diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl
index 35bc80b..2980370 100644
--- a/src/couchdb/couch_view.erl
+++ b/src/couchdb/couch_view.erl
@@ -96,13 +96,19 @@ cleanup_index_files(Db) ->
FileList = list_index_files(Db),
- % regex that matches all ddocs
- RegExp = "("++ string:join(Sigs, "|") ++")",
#!/bin/sh
#
# couchdb This is the init script for starting up the CouchDB server
#
# chkconfig: - 26 74
# description: Starts and stops the CouchDB daemon that handles \
# all database requests.
### BEGIN INIT INFO
# Provides: couchdb
start_link(Name, Options0) ->
Options = case couch_config:get("httpd", "extra_opts") of
undefined -> Options0;
StrOpts ->
try
{ok, Tokens, _} = erl_scan:string(StrOpts),
{ok, Options1} = erl_parse:parse_term(Tokens),
Options0 ++ Options1
catch
_Err:Msg ->