CouchDB
  1. CouchDB
  2. COUCHDB-1177

function_clause error in write_streamed_attachment

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.0.1, 1.0.2
    • Fix Version/s: 1.0.3, 1.1, 1.2
    • Component/s: None
    • Labels:
      None
    • Skill Level:
      Committers Level (Medium to Hard)

      Description

      LenLeft can still go negative. While the guard clause prevents an earlier bug, replication fails when it hits this issue.

      In the following case, LenLeft is -673327 which matches no clauses (we expect either 0 or > 0). Somehow we are starting with a LenLeft value lower than the number of bytes we subsequently receive.

      {function_clause,
      [

      {couch_db,write_streamed_attachment, [<0.13520.3>, #Fun<couch_rep_att.0.90652905>,-673327]}

      ,

      {couch_db,with_stream,3}

      ,

      {couch_db,'-doc_flush_atts/2-lc$^0/1-0-',2}

      ,

      {couch_db,doc_flush_atts,2}

      ,

      {couch_db,'-update_docs/4-lc$^3/1-3-',2}

      ,

      {couch_db,'-update_docs/4-lc$^2/1-2-',2},
      {couch_db,'-update_docs/4-lc$^2/1-2-',2}

      ,

      {couch_db,update_docs,4}

      ]}}

        Activity

        Hide
        Robert Newson added a comment -

        The code that reads attachments passed 0 for the length, which returns all data on the socket, even if that runs into the next request. The fix is to keep track of the expected remaining size and ask for no more than that each time.

        Show
        Robert Newson added a comment - The code that reads attachments passed 0 for the length, which returns all data on the socket, even if that runs into the next request. The fix is to keep track of the expected remaining size and ask for no more than that each time.
        Hide
        Jeff Snider added a comment -

        I have 1.1.1 pull replicating from 0.11.0 and it is failing with this bug. I have -165 instead of -673327 but other than that it looks like the same thing. Is this because I'm pulling from an old version or have I hit a regression? Crash report below. Thanks.

        [Thu, 15 Dec 2011 20:04:16 GMT] [error] [<0.8887.115>] {error_report,<0.30.0>,
        {<0.8887.115>,crash_report,
        [[{initial_call,
        {couch_rep_changes_feed,init,['Argument__1']}},

        {pid,<0.8887.115>}

        ,

        {registered_name,[]}

        ,
        {error_info,
        {exit,
        {function_clause,
        [

        {couch_db,write_streamed_attachment, [<0.8951.115>,#Fun<couch_rep_att.0.90652905>, -165]}

        ,

        {couch_db,with_stream,3}

        ,

        {couch_db,'-doc_flush_atts/2-lc$^0/1-0-',2}

        ,

        {couch_db,doc_flush_atts,2}

        ,

        {couch_db,'-update_docs/4-lc$^3/1-3-',2}

        ,

        {couch_db,'-update_docs/4-lc$^2/1-2-',2}

        ,

        {couch_db,update_docs,4}

        ,

        {couch_rep_writer,writer_loop,2}

        ]},
        [

        {gen_server,terminate,6}

        ,

        {proc_lib,init_p_do_apply,3}

        ]}},

        {ancestors, [<0.8886.115>,couch_rep_sup, couch_primary_services,couch_server_sup, <0.31.0>]}

        ,
        {messages,
        [{ibrowse_async_response,

        {1323,979450,92645}

        ,
        {error,closing_on_request}}]},

        {links,[]}

        ,
        {dictionary,
        [{timeout,
        {1323979487072182,#Ref<0.0.140.42031>}}]},

        {trap_exit,true}

        ,

        {status,running}

        ,

        {heap_size,6765}

        ,

        {stack_size,24}

        ,

        {reductions,138197}

        ],
        []]}}

        Show
        Jeff Snider added a comment - I have 1.1.1 pull replicating from 0.11.0 and it is failing with this bug. I have -165 instead of -673327 but other than that it looks like the same thing. Is this because I'm pulling from an old version or have I hit a regression? Crash report below. Thanks. [Thu, 15 Dec 2011 20:04:16 GMT] [error] [<0.8887.115>] {error_report,<0.30.0>, {<0.8887.115>,crash_report, [[{initial_call, {couch_rep_changes_feed,init, ['Argument__1'] }}, {pid,<0.8887.115>} , {registered_name,[]} , {error_info, {exit, {function_clause, [ {couch_db,write_streamed_attachment, [<0.8951.115>,#Fun<couch_rep_att.0.90652905>, -165]} , {couch_db,with_stream,3} , {couch_db,'-doc_flush_atts/2-lc$^0/1-0-',2} , {couch_db,doc_flush_atts,2} , {couch_db,'-update_docs/4-lc$^3/1-3-',2} , {couch_db,'-update_docs/4-lc$^2/1-2-',2} , {couch_db,update_docs,4} , {couch_rep_writer,writer_loop,2} ]}, [ {gen_server,terminate,6} , {proc_lib,init_p_do_apply,3} ]}}, {ancestors, [<0.8886.115>,couch_rep_sup, couch_primary_services,couch_server_sup, <0.31.0>]} , {messages, [{ibrowse_async_response, {1323,979450,92645} , {error,closing_on_request}}]}, {links,[]} , {dictionary, [{timeout, {1323979487072182,#Ref<0.0.140.42031>}}]}, {trap_exit,true} , {status,running} , {heap_size,6765} , {stack_size,24} , {reductions,138197} ], []]}}
        Hide
        Jens Alfke added a comment -

        This same exception has been reported against CouchDB 1.2 during a push from TouchDB.

        Here's the TouchDB bug report: https://github.com/couchbaselabs/TouchDB-iOS/issues/133
        and a pastie of the server log including the exception: http://pastebin.com/QefqXZsN

        Show
        Jens Alfke added a comment - This same exception has been reported against CouchDB 1.2 during a push from TouchDB. Here's the TouchDB bug report: https://github.com/couchbaselabs/TouchDB-iOS/issues/133 and a pastie of the server log including the exception: http://pastebin.com/QefqXZsN

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development