diff options
author | Nick Vatamaniuc <vatamane@apache.org> | 2020-02-17 16:34:50 -0500 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2020-03-02 12:26:22 -0600 |
commit | 293d3d51779a786452d2c4fd9e72ca9db6224e62 (patch) | |
tree | f34e42ae240b5f94ccf57d3aa72cae166e66a7c6 | |
parent | 78d7a9fd5e91dbd3d5f3b64b637802abb214dc90 (diff) | |
download | couchdb-293d3d51779a786452d2c4fd9e72ca9db6224e62.tar.gz |
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.
-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 3951fdb33..50a9effdb 100644 --- a/src/chttpd/src/chttpd_db.erl +++ b/src/chttpd/src/chttpd_db.erl @@ -86,13 +86,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(), |