You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ji...@apache.org on 2018/10/24 00:57:09 UTC

[couchdb] 01/01: Allow return with accepted for mixed nodes in cluster

This is an automated email from the ASF dual-hosted git repository.

jiangphcn pushed a commit to branch COUCHDB-3326-mixed-cluster
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit fe71879e9fd3a5d6c3075a6c9b8d558dcb8641ac
Author: jiangph <ji...@cn.ibm.com>
AuthorDate: Wed Oct 24 08:52:54 2018 +0800

    Allow return with accepted for mixed nodes in cluster
    
      - during mixed nodes in cluster, i.e. nodes with different releases,
      it is possible that "accep`ted" result is returned instead of ok when
      purge request is sent. This commit is used address badmatch error
      where "accepted" returned result is not considered.
    
    COUCHDB-3326
---
 src/chttpd/src/chttpd_db.erl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index bd01b93..f95c3e7 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -524,8 +524,11 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_purge">>]}=Req, Db) ->
         true -> ok
     end,
     couch_stats:increment_counter([couchdb, document_purges, total], length(IdsRevs2)),
-    {ok, Results} = fabric:purge_docs(Db, IdsRevs2, Options),
-    {Code, Json} = purge_results_to_json(IdsRevs2, Results),
+    Results2 = case fabric:purge_docs(Db, IdsRevs2, Options) of
+        {ok, Results} -> Results;
+        {accepted, Results} -> Results
+    end,
+    {Code, Json} = purge_results_to_json(IdsRevs2, Results2),
     send_json(Req, Code, {[{<<"purge_seq">>, null}, {<<"purged">>, {Json}}]});
 
 db_req(#httpd{path_parts=[_,<<"_purge">>]}=Req, _Db) ->