CouchDB
  1. CouchDB
  2. COUCHDB-822

body_too_large error for external processes, when body is 3MB

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.11
    • Fix Version/s: 1.3
    • Component/s: HTTP Interface
    • Labels:
      None
    • Environment:

      CouchDB 0.11 on Ubuntu 10.04,

    • Skill Level:
      Regular Contributors Level (Easy to Medium)

      Description

      I have a photo which is around 3 MB that I'm trying to PUT to an external process on the CouchDB database. The external process is called "_upload".
      I get an uncaught error "{exit,{body_too_large,content_length}}" in the logs when trying this. Smaller photos (around 60 kB) seem to work just fine.
      This just happens with external processes. I can upload the photo as an attachment directly to a document, with no problems.

      The error is similar to an earlier bug in the mochiweb library that was fixed around Feb 2009, where mochiweb never used the "max_document_size" setting that was provided when calling mochiweb_request:recv_body.

      I believe, supported by the stack trace below, that the cause for this bug is that in couch_httpd_external:json_req_obj the function mochiweb_request:recv_body/0 is called, which uses the mochiweb default value on MaxBody, which is 1 MB.
      I think that couch_httpd_external:json_req_obj should call mochiweb_request:recv_body/1 instead, with the "max_document_size" setting as the argument.

      Here are the error logs from one of my attempts:

      [Thu, 08 Jul 2010 18:49:53 GMT] [debug] [<0.3738.0>] 'PUT' /pillowfight/_upload/6b1908c352129ddda396fa69ac003d11

      {1,1}

      Headers: [

      {'Accept',"*/*"}

      ,

      {'Content-Length',"3093976"}

      ,

      {'Content-Type',"image/jpg"}

      ,

      {"Expect","100-continue"}

      ,

      {'Host',"localhost:5984"}

      ,

      {'User-Agent',"curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15"}

      ]

      [Thu, 08 Jul 2010 18:49:53 GMT] [debug] [<0.3738.0>] OAuth Params: []

      [Thu, 08 Jul 2010 18:49:53 GMT] [error] [<0.3738.0>] Uncaught error in HTTP request: {exit,{body_too_large,content_length}}

      [Thu, 08 Jul 2010 18:49:53 GMT] [info] [<0.3738.0>] Stacktrace: [

      {mochiweb_request,stream_body,5}

      ,

      {mochiweb_request,recv_body,2}

      ,

      {couch_httpd_external,json_req_obj,3}

      ,

      {couch_httpd_external,process_external_req,3}

      ,

      {couch_httpd_db,do_db_req,2}

      ,

      {couch_httpd,handle_request_int,5}

      ,

      {mochiweb_http,headers,5}

      ,

      {proc_lib,init_p_do_apply,3}

      ]

        Activity

        Hide
        Erik Edin added a comment -

        Removing unnecessary comment to avoid any confusion on what I meant with the logs.

        Show
        Erik Edin added a comment - Removing unnecessary comment to avoid any confusion on what I meant with the logs.
        Hide
        Benoit Chesneau added a comment -

        The max external body size should have its proper settings rather than using the max doc size. Different usages.

        Show
        Benoit Chesneau added a comment - The max external body size should have its proper settings rather than using the max doc size. Different usages.
        Hide
        Filipe Manana added a comment -

        I think the right approach here is something like this:
        https://github.com/apache/couchdb/commit/cc2379ebbd45d842204642ac8a6a5a16669ffa4e

        The case where the request doesn't have neither a content-length neither is chunked encoded, should be very rare (not http compliant). Therefore it doesn't make sense to have a new setting.

        Show
        Filipe Manana added a comment - I think the right approach here is something like this: https://github.com/apache/couchdb/commit/cc2379ebbd45d842204642ac8a6a5a16669ffa4e The case where the request doesn't have neither a content-length neither is chunked encoded, should be very rare (not http compliant). Therefore it doesn't make sense to have a new setting.
        Hide
        Jan Lehnardt added a comment -

        Bump to 1.3.x.

        Show
        Jan Lehnardt added a comment - Bump to 1.3.x.
        Hide
        Jason Smith added a comment -

        This bug was fixed by Bob Newson in fbac8ab4

        https://github.com/apache/couchdb/commit/fbac8ab4

        Show
        Jason Smith added a comment - This bug was fixed by Bob Newson in fbac8ab4 https://github.com/apache/couchdb/commit/fbac8ab4
        Hide
        Randall Leeds added a comment -

        Bob, if you can confirm what Jason says this appears fixed for 1.2. Update NEWS and CHANGES if necessary.

        Show
        Randall Leeds added a comment - Bob, if you can confirm what Jason says this appears fixed for 1.2. Update NEWS and CHANGES if necessary.
        Hide
        Robert Newson added a comment -

        This was fixed a while back, verified in master, 1.2.x, 1.3.x.

        Show
        Robert Newson added a comment - This was fixed a while back, verified in master, 1.2.x, 1.3.x.

          People

          • Assignee:
            Robert Newson
            Reporter:
            Erik Edin
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development