[couchdb] branch COUCHDB-3326-clustered-purge-pr3-refactor-pse-tests updated: Rename cpse_read_empty_docs/1

2018-06-21 Thread jiangphcn
This is an automated email from the ASF dual-hosted git repository.

jiangphcn pushed a commit to branch 
COUCHDB-3326-clustered-purge-pr3-refactor-pse-tests
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to 
refs/heads/COUCHDB-3326-clustered-purge-pr3-refactor-pse-tests by this push:
 new e2bbbf0  Rename cpse_read_empty_docs/1
e2bbbf0 is described below

commit e2bbbf098c6544f260c97462de5fdd2673991e56
Author: jiangphcn 
AuthorDate: Fri Jun 22 10:33:43 2018 +0800

Rename cpse_read_empty_docs/1

   - Rename cpse_read_empty_docs/1 to
 cpse_read_docs_from_empty_db/1

COUCHDB-3326
---
 src/couch_pse_tests/src/cpse_test_read_write_docs.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/couch_pse_tests/src/cpse_test_read_write_docs.erl 
b/src/couch_pse_tests/src/cpse_test_read_write_docs.erl
index 98509a9..84bf9f3 100644
--- a/src/couch_pse_tests/src/cpse_test_read_write_docs.erl
+++ b/src/couch_pse_tests/src/cpse_test_read_write_docs.erl
@@ -27,7 +27,7 @@ teardown_each(Db) ->
 ok = couch_server:delete(couch_db:name(Db), []).
 
 
-cpse_read_empty_docs(Db) ->
+cpse_read_docs_from_empty_db(Db) ->
 ?assertEqual([not_found], couch_db_engine:open_docs(Db, [<<"foo">>])),
 ?assertEqual(
 [not_found, not_found],



[couchdb] 02/04: Fix use of process_info(Pid, monitored_by)

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit be9441b5147da8e66c84536b193bd4c0b9e3730a
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 16:23:32 2018 -0500

Fix use of process_info(Pid, monitored_by)

This can now return references that are from NIFs monitoring the
process. This is important for the new file IO NIFs that monitor the
controlling process. For now we'll just take the easy way out by
filtering the references from our returned monitor lists.
---
 src/couch/src/couch_bt_engine.erl | 2 +-
 src/couch/src/couch_file.erl  | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/couch/src/couch_bt_engine.erl 
b/src/couch/src/couch_bt_engine.erl
index 43a77b0..7028997 100644
--- a/src/couch/src/couch_bt_engine.erl
+++ b/src/couch/src/couch_bt_engine.erl
@@ -185,7 +185,7 @@ decref(St) ->
 monitored_by(St) ->
 case erlang:process_info(St#st.fd, monitored_by) of
 {monitored_by, Pids} ->
-Pids;
+lists:filter(fun is_pid/1, Pids);
 _ ->
 []
 end.
diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index 9f668ea..af06b91 100644
--- a/src/couch/src/couch_file.erl
+++ b/src/couch/src/couch_file.erl
@@ -129,7 +129,7 @@ append_term_md5(Fd, Term, Options) ->
 
 append_binary(Fd, Bin) ->
 ioq:call(Fd, {append_bin, assemble_file_chunk(Bin)}, 
erlang:get(io_priority)).
-
+
 append_binary_md5(Fd, Bin) ->
 ioq:call(Fd,
 {append_bin, assemble_file_chunk(Bin, crypto:hash(md5, Bin))},
@@ -701,7 +701,8 @@ is_idle(#file{is_sys=true}) ->
 end;
 is_idle(#file{is_sys=false}) ->
 Tracker = whereis(couch_stats_process_tracker),
-case process_info(self(), monitored_by) of
+{monitored_by, PidsAndRefs} = process_info(self(), monitored_by),
+case lists:filter(fun is_pid/1, PidsAndRefs) of
 {monitored_by, []} -> true;
 {monitored_by, [Tracker]} -> true;
 {monitored_by, [_]} -> exit(tracker_monitoring_failed);



[couchdb] 03/04: TMP: Point to fixed mochiweb

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4619e90ccfc9d6a009cabc5b5961e8571ab3b804
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 13:10:09 2018 -0500

TMP: Point to fixed mochiweb
---
 rebar.config.script | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rebar.config.script b/rebar.config.script
index 82f4d70..ddf87cf 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -64,7 +64,8 @@ DepDescs = [
 {hyper,"hyper",{tag, "CouchDB-2.2.0-3"}},
 {ibrowse,  "ibrowse",  {tag, "CouchDB-4.0.1"}},
 {jiffy,"jiffy",{tag, "CouchDB-0.14.11-2"}},
-{mochiweb, "mochiweb", {tag, "v2.17.0"}},
+{mochiweb, {url, "https://github.com/cloudant/couchdb-mochiweb"},
+   {branch, "fix-parameterized-module-errors"}},
 {meck, "meck", {tag, "0.8.8"}},
 {bcrypt,   {url, "https://github.com/apache/couchdb-erlang-bcrypt"},
{tag, "1.0.2"}},



[couchdb] 01/04: Enable parameterized module calls

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 8229cfc0774371881708c78166ca0dacd2ea77c6
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 17:16:33 2018 -0500

Enable parameterized module calls

This is a temporary bandaid to allow us to continue using parameterized
modules with Erlang 21. We'll have to go back and modify every one of
these files to avoid that as well as figuring out how to upgrade
mochiweb to something that doesn't use parameterized modules by the time
they are fully removed from Erlang.
---
 src/chttpd/src/chttpd.erl | 3 +++
 src/chttpd/src/chttpd_db.erl  | 3 +++
 src/chttpd/src/chttpd_external.erl| 2 ++
 src/chttpd/src/chttpd_prefer_header.erl   | 1 +
 src/chttpd/src/chttpd_rewrite.erl | 3 +++
 src/chttpd/test/chttpd_prefer_header_test.erl | 3 +++
 src/couch/src/couch_httpd.erl | 3 +++
 src/couch/src/couch_httpd_auth.erl| 3 +++
 src/couch/src/couch_httpd_db.erl  | 3 +++
 src/couch/src/couch_httpd_external.erl| 2 ++
 src/couch/src/couch_httpd_proxy.erl   | 2 ++
 src/couch/src/couch_httpd_rewrite.erl | 3 +++
 src/couch/src/couch_httpd_vhost.erl   | 2 ++
 src/couch/test/couchdb_http_proxy_tests.erl   | 2 ++
 src/couch/test/test_web.erl   | 2 ++
 src/couch_index/src/couch_index.erl   | 2 ++
 src/fabric/src/fabric_doc_attachments.erl | 2 ++
 src/fabric/src/fabric_doc_atts.erl| 2 ++
 18 files changed, 43 insertions(+)

diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl
index ae94ae6..658b63c 100644
--- a/src/chttpd/src/chttpd.erl
+++ b/src/chttpd/src/chttpd.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(chttpd).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("chttpd/include/chttpd.hrl").
 
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index ed0adea..228ebf1 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(chttpd_db).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("couch_mrview/include/couch_mrview.hrl").
 
diff --git a/src/chttpd/src/chttpd_external.erl 
b/src/chttpd/src/chttpd_external.erl
index 64664b9..fa35c6b 100644
--- a/src/chttpd/src/chttpd_external.erl
+++ b/src/chttpd/src/chttpd_external.erl
@@ -12,6 +12,8 @@
 
 -module(chttpd_external).
 
+-compile(tuple_calls).
+
 -export([handle_external_req/2, handle_external_req/3]).
 -export([send_external_response/2]).
 -export([json_req_obj_fields/0, json_req_obj/2, json_req_obj/3, 
json_req_obj/4]).
diff --git a/src/chttpd/src/chttpd_prefer_header.erl 
b/src/chttpd/src/chttpd_prefer_header.erl
index f550e80..1ad1443 100644
--- a/src/chttpd/src/chttpd_prefer_header.erl
+++ b/src/chttpd/src/chttpd_prefer_header.erl
@@ -12,6 +12,7 @@
 
 -module(chttpd_prefer_header).
 
+-compile(tuple_calls).
 
 -export([
 maybe_return_minimal/2
diff --git a/src/chttpd/src/chttpd_rewrite.erl 
b/src/chttpd/src/chttpd_rewrite.erl
index 039390e..08c9ef3 100644
--- a/src/chttpd/src/chttpd_rewrite.erl
+++ b/src/chttpd/src/chttpd_rewrite.erl
@@ -16,6 +16,9 @@
 %% @doc Module for URL rewriting by pattern matching.
 
 -module(chttpd_rewrite).
+
+-compile(tuple_calls).
+
 -export([handle_rewrite_req/3]).
 -include_lib("couch/include/couch_db.hrl").
 
diff --git a/src/chttpd/test/chttpd_prefer_header_test.erl 
b/src/chttpd/test/chttpd_prefer_header_test.erl
index a8a5b3d..0f43ba4 100644
--- a/src/chttpd/test/chttpd_prefer_header_test.erl
+++ b/src/chttpd/test/chttpd_prefer_header_test.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(chttpd_prefer_header_test).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
diff --git a/src/couch/src/couch_httpd.erl b/src/couch/src/couch_httpd.erl
index 050282a..b4f01af 100644
--- a/src/couch/src/couch_httpd.erl
+++ b/src/couch/src/couch_httpd.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(couch_httpd).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 
 -export([start_link/0, start_link/1, stop/0, handle_request/5]).
diff --git a/src/couch/src/couch_httpd_auth.erl 
b/src/couch/src/couch_httpd_auth.erl
index 74cbe5a..edd71e8 100644
--- a/src/couch/src/couch_httpd_auth.erl
+++ b/src/couch/src/couch_httpd_auth.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(couch_httpd_auth).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 
 -export([party_mode_handler/1]).
diff --git a/src/couch/src/couch_httpd_db.erl b/src/couch/src/couch_httpd_db.erl
index 99b1192..220a032 100644
--- a/src/couch/src/couch_httpd_db.erl
+++ b/src/couch/src/couch_httpd_db.erl
@@ -11,6 +11,9 @@
 % the 

[couchdb] 04/04: TMP: fix rebar.config.script Erlang versions

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit fb5dba5b6d73d29271d07d5a3481902deed12399
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 16:28:56 2018 -0500

TMP: fix rebar.config.script Erlang versions
---
 rebar.config.script | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rebar.config.script b/rebar.config.script
index ddf87cf..1bf3969 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -94,7 +94,7 @@ ErlOpts = case os:getenv("ERL_OPTS") of
 end,
 
 AddConfig = [
-{require_otp_vsn, "R16B03|R16B03-1|17|18|19|20"},
+{require_otp_vsn, "R16B03|R16B03-1|17|18|19|20|21"},
 {deps_dir, "src"},
 {deps, lists:map(MakeDep, DepDescs)},
 {sub_dirs, SubDirs},



[couchdb] branch fix-erlang-21-eunit-failures updated (5b0f963 -> fb5dba5)

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard 5b0f963  squash to parameterized modules
 discard 6a6a525  TMP: fix rebar.config.script Erlang versions
 discard 05d0963  TMP: Point to fixed mochiweb
 discard 88a57d1  Fix use of process_info(Pid, monitored_by)
 discard da9fc4c  Fix Mochiweb parameterized module errors
 new 8229cfc  Enable parameterized module calls
 new be9441b  Fix use of process_info(Pid, monitored_by)
 new 4619e90  TMP: Point to fixed mochiweb
 new fb5dba5  TMP: fix rebar.config.script Erlang versions

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5b0f963)
\
 N -- N -- N   refs/heads/fix-erlang-21-eunit-failures (fb5dba5)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/chttpd/src/chttpd_prefer_header.erl   | 10 +-
 src/chttpd/test/chttpd_prefer_header_test.erl |  4 ++--
 src/couch/src/couch_httpd_auth.erl|  2 +-
 src/couch/src/couch_httpd_external.erl|  2 ++
 src/couch/src/couch_httpd_proxy.erl   |  4 ++--
 src/couch/src/couch_httpd_rewrite.erl | 12 ++--
 6 files changed, 18 insertions(+), 16 deletions(-)



[couchdb] branch fix-erlang-21-eunit-failures updated: squash to parameterized modules

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/fix-erlang-21-eunit-failures 
by this push:
 new 5b0f963  squash to parameterized modules
5b0f963 is described below

commit 5b0f963cce448f89250ae13981117544d147951b
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 16:43:56 2018 -0500

squash to parameterized modules
---
 src/couch_index/src/couch_index.erl | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/couch_index/src/couch_index.erl 
b/src/couch_index/src/couch_index.erl
index 8fba0a2..cae9577 100644
--- a/src/couch_index/src/couch_index.erl
+++ b/src/couch_index/src/couch_index.erl
@@ -13,6 +13,8 @@
 -module(couch_index).
 -behaviour(gen_server).
 
+-compile(tuple_calls).
+
 -vsn(3).
 
 %% API



[couchdb] 04/04: TMP: fix rebar.config.script Erlang versions

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 6a6a525fd10b5199347bbbeb28d89d0bbeca7d16
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 16:28:56 2018 -0500

TMP: fix rebar.config.script Erlang versions
---
 rebar.config.script | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rebar.config.script b/rebar.config.script
index ddf87cf..1bf3969 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -94,7 +94,7 @@ ErlOpts = case os:getenv("ERL_OPTS") of
 end,
 
 AddConfig = [
-{require_otp_vsn, "R16B03|R16B03-1|17|18|19|20"},
+{require_otp_vsn, "R16B03|R16B03-1|17|18|19|20|21"},
 {deps_dir, "src"},
 {deps, lists:map(MakeDep, DepDescs)},
 {sub_dirs, SubDirs},



[couchdb] 02/04: Fix use of process_info(Pid, monitored_by)

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 88a57d16ae7772b7ce18d5b1547e955f8a532358
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 16:23:32 2018 -0500

Fix use of process_info(Pid, monitored_by)

This can now return references that are from NIFs monitoring the
process. This is important for the new file IO NIFs that monitor the
controlling process. For now we'll just take the easy way out by
filtering the references from our returned monitor lists.
---
 src/couch/src/couch_bt_engine.erl | 2 +-
 src/couch/src/couch_file.erl  | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/couch/src/couch_bt_engine.erl 
b/src/couch/src/couch_bt_engine.erl
index 43a77b0..7028997 100644
--- a/src/couch/src/couch_bt_engine.erl
+++ b/src/couch/src/couch_bt_engine.erl
@@ -185,7 +185,7 @@ decref(St) ->
 monitored_by(St) ->
 case erlang:process_info(St#st.fd, monitored_by) of
 {monitored_by, Pids} ->
-Pids;
+lists:filter(fun is_pid/1, Pids);
 _ ->
 []
 end.
diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index 9f668ea..af06b91 100644
--- a/src/couch/src/couch_file.erl
+++ b/src/couch/src/couch_file.erl
@@ -129,7 +129,7 @@ append_term_md5(Fd, Term, Options) ->
 
 append_binary(Fd, Bin) ->
 ioq:call(Fd, {append_bin, assemble_file_chunk(Bin)}, 
erlang:get(io_priority)).
-
+
 append_binary_md5(Fd, Bin) ->
 ioq:call(Fd,
 {append_bin, assemble_file_chunk(Bin, crypto:hash(md5, Bin))},
@@ -701,7 +701,8 @@ is_idle(#file{is_sys=true}) ->
 end;
 is_idle(#file{is_sys=false}) ->
 Tracker = whereis(couch_stats_process_tracker),
-case process_info(self(), monitored_by) of
+{monitored_by, PidsAndRefs} = process_info(self(), monitored_by),
+case lists:filter(fun is_pid/1, PidsAndRefs) of
 {monitored_by, []} -> true;
 {monitored_by, [Tracker]} -> true;
 {monitored_by, [_]} -> exit(tracker_monitoring_failed);



[couchdb] 01/04: Fix Mochiweb parameterized module errors

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit da9fc4c31894ccf9e60fd1239c7809dec7c766c8
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 13:02:01 2018 -0500

Fix Mochiweb parameterized module errors
---
 src/chttpd/src/chttpd.erl |  3 +++
 src/chttpd/src/chttpd_db.erl  |  3 +++
 src/chttpd/src/chttpd_external.erl|  2 ++
 src/chttpd/src/chttpd_prefer_header.erl   | 11 ++-
 src/chttpd/src/chttpd_rewrite.erl |  3 +++
 src/chttpd/test/chttpd_prefer_header_test.erl |  7 +--
 src/couch/src/couch_httpd.erl |  3 +++
 src/couch/src/couch_httpd_auth.erl|  5 -
 src/couch/src/couch_httpd_db.erl  |  3 +++
 src/couch/src/couch_httpd_proxy.erl   |  6 --
 src/couch/src/couch_httpd_rewrite.erl | 15 +--
 src/couch/src/couch_httpd_vhost.erl   |  2 ++
 src/couch/test/couchdb_http_proxy_tests.erl   |  2 ++
 src/couch/test/test_web.erl   |  2 ++
 src/fabric/src/fabric_doc_attachments.erl |  2 ++
 src/fabric/src/fabric_doc_atts.erl|  2 ++
 16 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl
index ae94ae6..658b63c 100644
--- a/src/chttpd/src/chttpd.erl
+++ b/src/chttpd/src/chttpd.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(chttpd).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("chttpd/include/chttpd.hrl").
 
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index ed0adea..228ebf1 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(chttpd_db).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("couch_mrview/include/couch_mrview.hrl").
 
diff --git a/src/chttpd/src/chttpd_external.erl 
b/src/chttpd/src/chttpd_external.erl
index 64664b9..fa35c6b 100644
--- a/src/chttpd/src/chttpd_external.erl
+++ b/src/chttpd/src/chttpd_external.erl
@@ -12,6 +12,8 @@
 
 -module(chttpd_external).
 
+-compile(tuple_calls).
+
 -export([handle_external_req/2, handle_external_req/3]).
 -export([send_external_response/2]).
 -export([json_req_obj_fields/0, json_req_obj/2, json_req_obj/3, 
json_req_obj/4]).
diff --git a/src/chttpd/src/chttpd_prefer_header.erl 
b/src/chttpd/src/chttpd_prefer_header.erl
index f550e80..9028e41 100644
--- a/src/chttpd/src/chttpd_prefer_header.erl
+++ b/src/chttpd/src/chttpd_prefer_header.erl
@@ -12,6 +12,7 @@
 
 -module(chttpd_prefer_header).
 
+-compile(tuple_calls).
 
 -export([
 maybe_return_minimal/2
@@ -23,9 +24,9 @@
 
 maybe_return_minimal(#httpd{mochi_req = MochiReq}, Headers) ->
 case get_prefer_header(MochiReq) of
-"return=minimal" -> 
+"return=minimal" ->
 filter_headers(Headers, get_header_list());
-_ -> 
+_ ->
 Headers
 end.
 
@@ -34,13 +35,13 @@ get_prefer_header(Req) ->
 case Req:get_header_value("Prefer") of
 Value when is_list(Value) ->
 string:to_lower(Value);
-undefined -> 
+undefined ->
 undefined
 end.
 
 
 filter_headers(Headers, IncludeList) ->
-lists:filter(fun({HeaderName, _}) -> 
+lists:filter(fun({HeaderName, _}) ->
 lists:member(HeaderName, IncludeList)
 end, Headers).
 
@@ -51,4 +52,4 @@ get_header_list() ->
 
 
 split_list(S) ->
-re:split(S, "\\s*,\\s*", [trim, {return, list}]). 
+re:split(S, "\\s*,\\s*", [trim, {return, list}]).
diff --git a/src/chttpd/src/chttpd_rewrite.erl 
b/src/chttpd/src/chttpd_rewrite.erl
index 039390e..08c9ef3 100644
--- a/src/chttpd/src/chttpd_rewrite.erl
+++ b/src/chttpd/src/chttpd_rewrite.erl
@@ -16,6 +16,9 @@
 %% @doc Module for URL rewriting by pattern matching.
 
 -module(chttpd_rewrite).
+
+-compile(tuple_calls).
+
 -export([handle_rewrite_req/3]).
 -include_lib("couch/include/couch_db.hrl").
 
diff --git a/src/chttpd/test/chttpd_prefer_header_test.erl 
b/src/chttpd/test/chttpd_prefer_header_test.erl
index a8a5b3d..d4fc290 100644
--- a/src/chttpd/test/chttpd_prefer_header_test.erl
+++ b/src/chttpd/test/chttpd_prefer_header_test.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(chttpd_prefer_header_test).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
@@ -48,7 +51,7 @@ minimal_options_headers() ->
 
 default_no_exclude_header_test() ->
 Headers = chttpd_prefer_header:maybe_return_minimal(
-mock_request([]), 
+mock_request([]),
 default_headers()
 ),
 ?assertEqual(default_headers(), Headers).
@@ -67,7 +70,7 @@ empty_header_test() ->
 
 setup() ->
 ok = meck:new(config),
-ok = meck:expect(config, get, fun("chttpd", 

[couchdb] 03/04: TMP: Point to fixed mochiweb

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 05d0963d72013865aec1256c09c0da809f0c4641
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 13:10:09 2018 -0500

TMP: Point to fixed mochiweb
---
 rebar.config.script | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rebar.config.script b/rebar.config.script
index 82f4d70..ddf87cf 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -64,7 +64,8 @@ DepDescs = [
 {hyper,"hyper",{tag, "CouchDB-2.2.0-3"}},
 {ibrowse,  "ibrowse",  {tag, "CouchDB-4.0.1"}},
 {jiffy,"jiffy",{tag, "CouchDB-0.14.11-2"}},
-{mochiweb, "mochiweb", {tag, "v2.17.0"}},
+{mochiweb, {url, "https://github.com/cloudant/couchdb-mochiweb"},
+   {branch, "fix-parameterized-module-errors"}},
 {meck, "meck", {tag, "0.8.8"}},
 {bcrypt,   {url, "https://github.com/apache/couchdb-erlang-bcrypt"},
{tag, "1.0.2"}},



[couchdb] branch fix-erlang-21-eunit-failures updated (5d29224 -> 6a6a525)

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard 5d29224  TMP: fix rebar.config.script Erlang versions
 discard b82f0d8  TMP: Point to fixed mochiweb
 discard 4796f8c  Fix use of process_info(Pid, monitored_by)
 discard 5c93d7c  Fix Mochiweb parameterized module errors
 new da9fc4c  Fix Mochiweb parameterized module errors
 new 88a57d1  Fix use of process_info(Pid, monitored_by)
 new 05d0963  TMP: Point to fixed mochiweb
 new 6a6a525  TMP: fix rebar.config.script Erlang versions

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5d29224)
\
 N -- N -- N   refs/heads/fix-erlang-21-eunit-failures (6a6a525)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/couch/test/couchdb_http_proxy_tests.erl | 2 ++
 src/couch/test/test_web.erl | 2 ++
 2 files changed, 4 insertions(+)



[couchdb] 04/04: TMP: fix rebar.config.script Erlang versions

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 5d29224da61541794e27b8ec052e2aa59a5fb280
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 16:28:56 2018 -0500

TMP: fix rebar.config.script Erlang versions
---
 rebar.config.script | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rebar.config.script b/rebar.config.script
index ddf87cf..1bf3969 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -94,7 +94,7 @@ ErlOpts = case os:getenv("ERL_OPTS") of
 end,
 
 AddConfig = [
-{require_otp_vsn, "R16B03|R16B03-1|17|18|19|20"},
+{require_otp_vsn, "R16B03|R16B03-1|17|18|19|20|21"},
 {deps_dir, "src"},
 {deps, lists:map(MakeDep, DepDescs)},
 {sub_dirs, SubDirs},



[couchdb] 02/04: Fix use of process_info(Pid, monitored_by)

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4796f8cc9bcd05362ba2de1d67ff5e964f7514ba
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 16:23:32 2018 -0500

Fix use of process_info(Pid, monitored_by)

This can now return references that are from NIFs monitoring the
process. This is important for the new file IO NIFs that monitor the
controlling process. For now we'll just take the easy way out by
filtering the references from our returned monitor lists.
---
 src/couch/src/couch_bt_engine.erl | 2 +-
 src/couch/src/couch_file.erl  | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/couch/src/couch_bt_engine.erl 
b/src/couch/src/couch_bt_engine.erl
index 43a77b0..7028997 100644
--- a/src/couch/src/couch_bt_engine.erl
+++ b/src/couch/src/couch_bt_engine.erl
@@ -185,7 +185,7 @@ decref(St) ->
 monitored_by(St) ->
 case erlang:process_info(St#st.fd, monitored_by) of
 {monitored_by, Pids} ->
-Pids;
+lists:filter(fun is_pid/1, Pids);
 _ ->
 []
 end.
diff --git a/src/couch/src/couch_file.erl b/src/couch/src/couch_file.erl
index 9f668ea..af06b91 100644
--- a/src/couch/src/couch_file.erl
+++ b/src/couch/src/couch_file.erl
@@ -129,7 +129,7 @@ append_term_md5(Fd, Term, Options) ->
 
 append_binary(Fd, Bin) ->
 ioq:call(Fd, {append_bin, assemble_file_chunk(Bin)}, 
erlang:get(io_priority)).
-
+
 append_binary_md5(Fd, Bin) ->
 ioq:call(Fd,
 {append_bin, assemble_file_chunk(Bin, crypto:hash(md5, Bin))},
@@ -701,7 +701,8 @@ is_idle(#file{is_sys=true}) ->
 end;
 is_idle(#file{is_sys=false}) ->
 Tracker = whereis(couch_stats_process_tracker),
-case process_info(self(), monitored_by) of
+{monitored_by, PidsAndRefs} = process_info(self(), monitored_by),
+case lists:filter(fun is_pid/1, PidsAndRefs) of
 {monitored_by, []} -> true;
 {monitored_by, [Tracker]} -> true;
 {monitored_by, [_]} -> exit(tracker_monitoring_failed);



[couchdb] branch fix-erlang-21-eunit-failures updated (e5833ba -> 5d29224)

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard e5833ba  TMP: Point to fixed mochiweb
 discard d9f053b  Fix Mochiweb parameterized module errors
 new 5c93d7c  Fix Mochiweb parameterized module errors
 new 4796f8c  Fix use of process_info(Pid, monitored_by)
 new b82f0d8  TMP: Point to fixed mochiweb
 new 5d29224  TMP: fix rebar.config.script Erlang versions

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (e5833ba)
\
 N -- N -- N   refs/heads/fix-erlang-21-eunit-failures (5d29224)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 rebar.config.script| 2 +-
 src/chttpd/src/chttpd_external.erl | 2 ++
 src/couch/src/couch_bt_engine.erl  | 2 +-
 src/couch/src/couch_file.erl   | 5 +++--
 4 files changed, 7 insertions(+), 4 deletions(-)



[couchdb] 01/04: Fix Mochiweb parameterized module errors

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 5c93d7c3c49801a955c1a4a9d8ae266f2d3bbe69
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 13:02:01 2018 -0500

Fix Mochiweb parameterized module errors
---
 src/chttpd/src/chttpd.erl |  3 +++
 src/chttpd/src/chttpd_db.erl  |  3 +++
 src/chttpd/src/chttpd_external.erl|  2 ++
 src/chttpd/src/chttpd_prefer_header.erl   | 11 ++-
 src/chttpd/src/chttpd_rewrite.erl |  3 +++
 src/chttpd/test/chttpd_prefer_header_test.erl |  7 +--
 src/couch/src/couch_httpd.erl |  3 +++
 src/couch/src/couch_httpd_auth.erl|  5 -
 src/couch/src/couch_httpd_db.erl  |  3 +++
 src/couch/src/couch_httpd_proxy.erl   |  6 --
 src/couch/src/couch_httpd_rewrite.erl | 15 +--
 src/couch/src/couch_httpd_vhost.erl   |  2 ++
 src/fabric/src/fabric_doc_attachments.erl |  2 ++
 src/fabric/src/fabric_doc_atts.erl|  2 ++
 14 files changed, 51 insertions(+), 16 deletions(-)

diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl
index ae94ae6..658b63c 100644
--- a/src/chttpd/src/chttpd.erl
+++ b/src/chttpd/src/chttpd.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(chttpd).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("chttpd/include/chttpd.hrl").
 
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index ed0adea..228ebf1 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(chttpd_db).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("couch_mrview/include/couch_mrview.hrl").
 
diff --git a/src/chttpd/src/chttpd_external.erl 
b/src/chttpd/src/chttpd_external.erl
index 64664b9..fa35c6b 100644
--- a/src/chttpd/src/chttpd_external.erl
+++ b/src/chttpd/src/chttpd_external.erl
@@ -12,6 +12,8 @@
 
 -module(chttpd_external).
 
+-compile(tuple_calls).
+
 -export([handle_external_req/2, handle_external_req/3]).
 -export([send_external_response/2]).
 -export([json_req_obj_fields/0, json_req_obj/2, json_req_obj/3, 
json_req_obj/4]).
diff --git a/src/chttpd/src/chttpd_prefer_header.erl 
b/src/chttpd/src/chttpd_prefer_header.erl
index f550e80..9028e41 100644
--- a/src/chttpd/src/chttpd_prefer_header.erl
+++ b/src/chttpd/src/chttpd_prefer_header.erl
@@ -12,6 +12,7 @@
 
 -module(chttpd_prefer_header).
 
+-compile(tuple_calls).
 
 -export([
 maybe_return_minimal/2
@@ -23,9 +24,9 @@
 
 maybe_return_minimal(#httpd{mochi_req = MochiReq}, Headers) ->
 case get_prefer_header(MochiReq) of
-"return=minimal" -> 
+"return=minimal" ->
 filter_headers(Headers, get_header_list());
-_ -> 
+_ ->
 Headers
 end.
 
@@ -34,13 +35,13 @@ get_prefer_header(Req) ->
 case Req:get_header_value("Prefer") of
 Value when is_list(Value) ->
 string:to_lower(Value);
-undefined -> 
+undefined ->
 undefined
 end.
 
 
 filter_headers(Headers, IncludeList) ->
-lists:filter(fun({HeaderName, _}) -> 
+lists:filter(fun({HeaderName, _}) ->
 lists:member(HeaderName, IncludeList)
 end, Headers).
 
@@ -51,4 +52,4 @@ get_header_list() ->
 
 
 split_list(S) ->
-re:split(S, "\\s*,\\s*", [trim, {return, list}]). 
+re:split(S, "\\s*,\\s*", [trim, {return, list}]).
diff --git a/src/chttpd/src/chttpd_rewrite.erl 
b/src/chttpd/src/chttpd_rewrite.erl
index 039390e..08c9ef3 100644
--- a/src/chttpd/src/chttpd_rewrite.erl
+++ b/src/chttpd/src/chttpd_rewrite.erl
@@ -16,6 +16,9 @@
 %% @doc Module for URL rewriting by pattern matching.
 
 -module(chttpd_rewrite).
+
+-compile(tuple_calls).
+
 -export([handle_rewrite_req/3]).
 -include_lib("couch/include/couch_db.hrl").
 
diff --git a/src/chttpd/test/chttpd_prefer_header_test.erl 
b/src/chttpd/test/chttpd_prefer_header_test.erl
index a8a5b3d..d4fc290 100644
--- a/src/chttpd/test/chttpd_prefer_header_test.erl
+++ b/src/chttpd/test/chttpd_prefer_header_test.erl
@@ -11,6 +11,9 @@
 % the License.
 
 -module(chttpd_prefer_header_test).
+
+-compile(tuple_calls).
+
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
@@ -48,7 +51,7 @@ minimal_options_headers() ->
 
 default_no_exclude_header_test() ->
 Headers = chttpd_prefer_header:maybe_return_minimal(
-mock_request([]), 
+mock_request([]),
 default_headers()
 ),
 ?assertEqual(default_headers(), Headers).
@@ -67,7 +70,7 @@ empty_header_test() ->
 
 setup() ->
 ok = meck:new(config),
-ok = meck:expect(config, get, fun("chttpd", "prefer_minimal",  _) -> 
+ok = meck:expect(config, get, fun("chttpd", "prefer_minimal",  _) ->
 

[couchdb] 03/04: TMP: Point to fixed mochiweb

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit b82f0d8f4bc44c0baab176cebab2c2187ab358f3
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 13:10:09 2018 -0500

TMP: Point to fixed mochiweb
---
 rebar.config.script | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rebar.config.script b/rebar.config.script
index 82f4d70..ddf87cf 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -64,7 +64,8 @@ DepDescs = [
 {hyper,"hyper",{tag, "CouchDB-2.2.0-3"}},
 {ibrowse,  "ibrowse",  {tag, "CouchDB-4.0.1"}},
 {jiffy,"jiffy",{tag, "CouchDB-0.14.11-2"}},
-{mochiweb, "mochiweb", {tag, "v2.17.0"}},
+{mochiweb, {url, "https://github.com/cloudant/couchdb-mochiweb"},
+   {branch, "fix-parameterized-module-errors"}},
 {meck, "meck", {tag, "0.8.8"}},
 {bcrypt,   {url, "https://github.com/apache/couchdb-erlang-bcrypt"},
{tag, "1.0.2"}},



[couchdb] branch master updated: Update snappy dep to CouchDB-1.0.1 with 21.0 support

2018-06-21 Thread vatamane
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/master by this push:
 new 103a062  Update snappy dep to CouchDB-1.0.1 with 21.0 support
103a062 is described below

commit 103a0624f309ea0d796176a55eb5faea68f26047
Author: Nick Vatamaniuc 
AuthorDate: Thu Jun 21 14:07:25 2018 -0400

Update snappy dep to CouchDB-1.0.1 with 21.0 support

Issue #1396
---
 rebar.config.script | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rebar.config.script b/rebar.config.script
index 82f4d70..a393c87 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -51,7 +51,7 @@ DepDescs = [
 {b64url,   "b64url",   {tag, "1.0.1"}},
 {ets_lru,  "ets-lru",  {tag, "1.0.0"}},
 {khash,"khash",{tag, "1.0.1"}},
-{snappy,   "snappy",   {tag, "CouchDB-1.0.0"}},
+{snappy,   "snappy",   {tag, "CouchDB-1.0.1"}},
 {ioq,  "ioq",  {tag, "1.0.1"}},
 
 %% Non-Erlang deps



[couchdb] branch fix-erlang-21-eunit-failures updated: TMP: Point to fixed mochiweb

2018-06-21 Thread davisp
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/fix-erlang-21-eunit-failures 
by this push:
 new e5833ba  TMP: Point to fixed mochiweb
e5833ba is described below

commit e5833ba48e43dff92cb37f3313493bdf152741f3
Author: Paul J. Davis 
AuthorDate: Thu Jun 21 13:10:09 2018 -0500

TMP: Point to fixed mochiweb
---
 rebar.config.script | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rebar.config.script b/rebar.config.script
index 82f4d70..ddf87cf 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -64,7 +64,8 @@ DepDescs = [
 {hyper,"hyper",{tag, "CouchDB-2.2.0-3"}},
 {ibrowse,  "ibrowse",  {tag, "CouchDB-4.0.1"}},
 {jiffy,"jiffy",{tag, "CouchDB-0.14.11-2"}},
-{mochiweb, "mochiweb", {tag, "v2.17.0"}},
+{mochiweb, {url, "https://github.com/cloudant/couchdb-mochiweb"},
+   {branch, "fix-parameterized-module-errors"}},
 {meck, "meck", {tag, "0.8.8"}},
 {bcrypt,   {url, "https://github.com/apache/couchdb-erlang-bcrypt"},
{tag, "1.0.2"}},



[couchdb-snappy] Git Push Summary

2018-06-21 Thread vatamane
Repository: couchdb-snappy
Updated Tags:  refs/tags/CouchDB-1.0.1 [created] deb2489ed


snappy commit: updated refs/heads/master to deb2489

2018-06-21 Thread vatamane
Repository: couchdb-snappy
Updated Branches:
  refs/heads/master 1a1205f1e -> deb2489ed


Build with Erlang 21

Issue #1396


Project: http://git-wip-us.apache.org/repos/asf/couchdb-snappy/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-snappy/commit/deb2489e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-snappy/tree/deb2489e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-snappy/diff/deb2489e

Branch: refs/heads/master
Commit: deb2489ed99e05e3f204378d36e7cde01b485197
Parents: 1a1205f
Author: Nick Vatamaniuc 
Authored: Wed Jun 20 17:15:14 2018 -0400
Committer: Nick Vatamaniuc 
Committed: Thu Jun 21 13:12:53 2018 -0400

--
 rebar.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/couchdb-snappy/blob/deb2489e/rebar.config
--
diff --git a/rebar.config b/rebar.config
index 289fed3..f134a63 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,4 +1,4 @@
-{require_otp_vsn, "R14|R15|R16|17|18|19|20"}.
+{require_otp_vsn, "R14|R15|R16|17|18|19|20|21"}.
 
 {erl_opts, [debug_info, warn_unused_vars, warn_shadow_vars, 
warn_unused_import]}.
 {port_sources, ["c_src/*.cc", 



[couchdb] branch COUCHDB-3326-clustered-purge-pr5-implementation updated: Refactor on EPI approach

2018-06-21 Thread jiangphcn
This is an automated email from the ASF dual-hosted git repository.

jiangphcn pushed a commit to branch 
COUCHDB-3326-clustered-purge-pr5-implementation
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to 
refs/heads/COUCHDB-3326-clustered-purge-pr5-implementation by this push:
 new 9556d86  Refactor on EPI approach
9556d86 is described below

commit 9556d86920266a1ecdeb838055f43407056051d8
Author: jiangphcn 
AuthorDate: Thu Jun 21 21:34:49 2018 +0800

Refactor on EPI approach

   - add error handling
   - simplfy verify_index_exists/1

COUCHDB-3326
---
 src/couch/src/couch_db.erl | 16 +---
 src/couch_mrview/src/couch_mrview_index.erl| 43 +-
 .../test/couch_mrview_purge_docs_tests.erl |  1 -
 3 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index bbf7537..ed089fb 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -477,22 +477,28 @@ purge_client_exists(DbName, DocId, Props) ->
 try
 Type = couch_util:get_value(<<"type">>, Props),
 CheckFun = get_purge_client_fun(Type),
+if CheckFun =/= undefined -> ok; true ->
+Fmt1 = "Failed to get client function using '~p' document in
+database '~p'",
+couch_log:error(Fmt1, [DbName, DocId]),
+throw(failed)
+end,
 Exists = CheckFun(Props),
 if not Exists -> ok; true ->
 Updated = couch_util:get_value(<<"updated_on">>, Props),
 if is_integer(Updated) and Updated > LagThreshold -> ok; true ->
 Diff = NowSecs - Updated,
-Fmt1 = "Purge checkpoint '~s' not updated in ~p seconds",
-couch_log:error(Fmt1, [DocId, Diff])
+Fmt2 = "Purge checkpoint '~s' not updated in ~p seconds",
+couch_log:error(Fmt2, [DocId, Diff])
 end
 end,
 Exists
 catch _:_ ->
 % If we fail to check for a client we have to assume that
 % it exists.
-Fmt2 = "Failed to check purge checkpoint using
-document '~p' on database ~p",
-couch_log:error(Fmt2, [DbName, DocId]),
+Fmt3 = "Failed to check purge checkpoint using
+document '~p' in database ~p",
+couch_log:error(Fmt3, [DbName, DocId]),
 true
 end.
 
diff --git a/src/couch_mrview/src/couch_mrview_index.erl 
b/src/couch_mrview/src/couch_mrview_index.erl
index 02b8941..e8457f7 100644
--- a/src/couch_mrview/src/couch_mrview_index.erl
+++ b/src/couch_mrview/src/couch_mrview_index.erl
@@ -232,33 +232,26 @@ verify_index_exists(Props) ->
 <<"signature">>,
 Props
 ),
-case couch_db:open_int(ShardDbName, []) of
-{ok, Db} ->
-try
-DbName = mem3:dbname(couch_db:name(Db)),
-case ddoc_cache:open(DbName, DDocId) of
-{ok, DDoc} ->
-{ok, IdxState} = couch_mrview_util:ddoc_to_mrst(
-ShardDbName,
-DDoc
-),
-IdxSig = IdxState#mrst.sig,
-couch_index_util:hexsig(IdxSig) == SigInLocal;
-_Else ->
-false
-end
-catch E:T ->
-Stack = erlang:get_stacktrace(),
-couch_log:error(
-"Error occurs when verifying existence of ~s/~s :: ~p ~p",
-[ShardDbName, DDocId, {E, T}, Stack]
+try
+DbName = mem3:dbname(ShardDbName),
+case ddoc_cache:open(DbName, DDocId) of
+{ok, DDoc} ->
+{ok, IdxState} = couch_mrview_util:ddoc_to_mrst(
+ShardDbName,
+DDoc
 ),
+IdxSig = IdxState#mrst.sig,
+couch_index_util:hexsig(IdxSig) == SigInLocal;
+_Else ->
 false
-after
-catch couch_db:close(Db)
-end;
-_ ->
-false
+end
+catch E:T ->
+Stack = erlang:get_stacktrace(),
+couch_log:error(
+"Error occurs when verifying existence of ~s/~s :: ~p ~p",
+[ShardDbName, DDocId, {E, T}, Stack]
+),
+false
 end.
 
 
diff --git a/src/couch_mrview/test/couch_mrview_purge_docs_tests.erl 
b/src/couch_mrview/test/couch_mrview_purge_docs_tests.erl
index d5bf9f6..6aa7a0e 100644
--- a/src/couch_mrview/test/couch_mrview_purge_docs_tests.erl
+++ b/src/couch_mrview/test/couch_mrview_purge_docs_tests.erl
@@ -375,7 +375,6 @@ test_purge_compact_for_stale_purge_cp_with_client(Db) ->
 % run query again to reflect purge requests
 % to mrview
 {ok, Db2} = couch_db:reopen(Db1),
-_Result1 = 

[couchdb] branch COUCHDB-3326-clustered-purge-pr5-implementation updated: Address Ilya's comments

2018-06-21 Thread jiangphcn
This is an automated email from the ASF dual-hosted git repository.

jiangphcn pushed a commit to branch 
COUCHDB-3326-clustered-purge-pr5-implementation
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to 
refs/heads/COUCHDB-3326-clustered-purge-pr5-implementation by this push:
 new 407b1dc  Address Ilya's comments
407b1dc is described below

commit 407b1dcd337f3e54c051c3cfa7e671726ff6bb7e
Author: jiangphcn 
AuthorDate: Thu Jun 21 16:10:06 2018 +0800

Address Ilya's comments

   - use EPI decider to perform indexer existence checker function
   - swap "stop_couch/1" and "remove files"
   - refactor reason for throw bad_request
   - directly use meck:unload/0

COUCHDB-3326
---
 src/couch/src/couch_db.erl | 37 
 src/couch/src/couch_db_plugin.erl  |  4 ++
 src/couch/test/couch_bt_engine_upgrade_tests.erl   |  4 +-
 .../src/couch_index_plugin_couch_db.erl| 10 +
 src/couch_mrview/src/couch_mrview_index.erl|  2 -
 src/couch_mrview/src/couch_mrview_util.erl |  5 +--
 .../test/couch_mrview_purge_docs_fabric_tests.erl  |  2 +-
 .../src/cpse_test_purge_bad_checkpoints.erl| 49 ++
 src/mem3/src/mem3_epi.erl  |  3 +-
 .../src/mem3_plugin_couch_db.erl}  | 13 --
 src/mem3/src/mem3_rep.erl  |  6 +--
 11 files changed, 44 insertions(+), 91 deletions(-)

diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index 2645ea2..bbf7537 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -81,7 +81,7 @@
 
 get_minimum_purge_seq/1,
 purge_client_exists/3,
-get_purge_client_fun/2,
+get_purge_client_fun/1,
 
 update_doc/3,
 update_doc/4,
@@ -475,7 +475,8 @@ purge_client_exists(DbName, DocId, Props) ->
 LagThreshold = NowSecs - LagWindow,
 
 try
-CheckFun = get_purge_client_fun(DocId, Props),
+Type = couch_util:get_value(<<"type">>, Props),
+CheckFun = get_purge_client_fun(Type),
 Exists = CheckFun(Props),
 if not Exists -> ok; true ->
 Updated = couch_util:get_value(<<"updated_on">>, Props),
@@ -496,33 +497,13 @@ purge_client_exists(DbName, DocId, Props) ->
 end.
 
 
-get_purge_client_fun(DocId, Props) ->
-M0 = couch_util:get_value(<<"verify_module">>, Props),
-M = try
-binary_to_existing_atom(M0, latin1)
-catch error:badarg ->
-Fmt1 = "Missing index module '~p' for purge checkpoint '~s'",
-couch_log:error(Fmt1, [M0, DocId]),
-throw(failed)
-end,
+get_purge_client_fun(Type) ->
+couch_db_plugin:get_purge_client_fun(
+Type, fun get_purge_client_fun_int/1).
 
-F0 = couch_util:get_value(<<"verify_function">>, Props),
-try
-F = binary_to_existing_atom(F0, latin1),
-case erlang:function_exported(M, F, 1) of
-true ->
-fun M:F/1;
-false ->
-Fmt2 = "Missing exported function '~p' in '~p'
-for purge checkpoint '~s'",
-couch_log:error(Fmt2, [F0, M0, DocId]),
-throw(failed)
-end
-catch error:badarg ->
-Fmt3 = "Missing function '~p' in '~p' for purge checkpoint '~s'",
-couch_log:error(Fmt3, [F0, M0, DocId]),
-throw(failed)
-end.
+
+get_purge_client_fun_int(_Type) ->
+undefined.
 
 
 set_purge_infos_limit(#db{main_pid=Pid}=Db, Limit) when Limit > 0 ->
diff --git a/src/couch/src/couch_db_plugin.erl 
b/src/couch/src/couch_db_plugin.erl
index 8163256..2f61464 100644
--- a/src/couch/src/couch_db_plugin.erl
+++ b/src/couch/src/couch_db_plugin.erl
@@ -18,6 +18,7 @@
 after_doc_read/2,
 validate_docid/1,
 check_is_admin/1,
+get_purge_client_fun/2,
 on_compact/2,
 on_delete/2
 ]).
@@ -57,6 +58,9 @@ check_is_admin(Db) ->
 %% callbacks return true only if it specifically allow the given Id
 couch_epi:any(Handle, ?SERVICE_ID, check_is_admin, [Db], []).
 
+get_purge_client_fun(Type, Default) ->
+maybe_handle(get_purge_client_fun, [Type], Default).
+
 on_compact(DbName, DDocs) ->
 Handle = couch_epi:get_handle(?SERVICE_ID),
 couch_epi:apply(Handle, ?SERVICE_ID, on_compact, [DbName, DDocs], []).
diff --git a/src/couch/test/couch_bt_engine_upgrade_tests.erl 
b/src/couch/test/couch_bt_engine_upgrade_tests.erl
index 6aef366..8c748f8 100644
--- a/src/couch/test/couch_bt_engine_upgrade_tests.erl
+++ b/src/couch/test/couch_bt_engine_upgrade_tests.erl
@@ -37,10 +37,10 @@ setup() ->
 
 
 teardown({Ctx, Paths}) ->
+test_util:stop_couch(Ctx),
 lists:foreach(fun(Path) ->
 file:delete(Path)
-end, Paths),
-test_util:stop_couch(Ctx).
+end, Paths).
 
 
 upgrade_test_() ->
diff --git a/src/couch_index/src/couch_index_plugin_couch_db.erl