diff options
author | Nick Vatamaniuc <vatamane@apache.org> | 2020-02-17 16:34:50 -0500 |
---|---|---|
committer | Nick Vatamaniuc <vatamane@apache.org> | 2020-02-17 16:38:45 -0500 |
commit | d26b3207752e53a553ae6fce6cb3dc11291c3baf (patch) | |
tree | cb0003f83ea1382f57bb821e6ff8e6ed058e0487 | |
parent | 1fd40cef8eb1d646ed38e240ccb3bde99b71bd8b (diff) | |
download | couchdb-changes-include-docs-in-same-tx.tar.gz |
Re-use changes feed main transaction when including docschanges-include-docs-in-same-tx
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.
-rw-r--r-- | src/chttpd/src/chttpd_db.erl | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl index 2e3af2064..0c47eb995 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(), |