You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2020/02/17 21:45:31 UTC

[couchdb] 01/01: Re-use changes feed main transaction when including docs

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

vatamane pushed a commit to branch changes-include-docs-in-same-tx
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d26b3207752e53a553ae6fce6cb3dc11291c3baf
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Mon Feb 17 16:34:50 2020 -0500

    Re-use changes feed main transaction when including docs
    
    Previously each doc was read in a separate transaction. It turns out that size
    limits do not apply to read-only transactions so we don't have to worry about
    that here. Also transaction restart are already implemented so we don't have to
    worry about timeout either.
---
 src/chttpd/src/chttpd_db.erl | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index 2e3af20..0c47eb9 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -85,13 +85,17 @@ handle_request(#httpd{path_parts=[DbName|RestParts],method=Method}=Req)->
 
 handle_changes_req(#httpd{method='POST'}=Req, Db) ->
     chttpd:validate_ctype(Req, "application/json"),
-    handle_changes_req1(Req, Db);
+    fabric2_fdb:transactional(Db, fun(TxDb) ->
+        handle_changes_req_tx(Req, TxDb)
+    end);
 handle_changes_req(#httpd{method='GET'}=Req, Db) ->
-    handle_changes_req1(Req, Db);
+    fabric2_fdb:transactional(Db, fun(TxDb) ->
+        handle_changes_req_tx(Req, TxDb)
+    end);
 handle_changes_req(#httpd{path_parts=[_,<<"_changes">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "GET,POST,HEAD").
 
-handle_changes_req1(#httpd{}=Req, Db) ->
+handle_changes_req_tx(#httpd{}=Req, Db) ->
     ChangesArgs = parse_changes_query(Req),
     ChangesFun = chttpd_changes:handle_db_changes(ChangesArgs, Req, Db),
     Max = chttpd:chunked_response_buffer_size(),