nickva opened a new pull request, #6071:
URL: https://github.com/apache/couchdb/pull/6071

   Previously, if a multipart parser reached an eof before the declared length, 
it still let the writer wait and timeout (300s). This was especially noticed if 
users toggled `serialize_worker_startup=true`. Then, the first worker would 
buffer all the data (another undesirable behavior) until it reached a premature 
eof and then get stuck. Other workers wouldn't start either and the request 
would eventually crash.
   
   Here we fix both issues:
   
    1) If we detect serialize_worker_startup=true then we switch back to the
    default parallel worker startup pattern. This how the MP parser was built to
    work. Otherwise it would buffer the whole attachment into memory until the
    first worker wasn't done and the others started. That defies the purpose of
    incremental attachment uploads. So to go with the grain of MP parser design 
we
    switch back to parallel worker startup.
   
    2) Let writers which wait on an EOF exit instead of deadlocking until a
    timeout. Writer waits for more bytes when the stream already reached EOF is
    because the user uploaded less than the declared number of bytes (attachment
    is too short). In that case we exit normally and let the parser monitors 
fire
    with `"attachment shorter than expected"` error.
   
   Reproducer for the issue:
   
    * start dev/run cluster with 3 nodes
    * `s:multicall(fun() -> config:set("fabric", 
"serialize_worker_startup","true") end)`
    * curl -XPUT 'http://adm:[email protected]:15984/mptest'
   
   Before PR:
   
   ```
   curl  --max-time 10 -XPUT 'http://adm:[email protected]:15984/mptest/short' -H 
'Content-Type: multipart/related;boundary="abc123"' --data-binary 
$'--abc123\r\nContent-Type: 
application/json\r\n\r\n{"_attachments":{"ohai":{"follows":true,"content_type":"text/plain","length":
 4}}}\r\n--abc123\r\n\r\noha\r\n--abc123--'
   curl: (28) Operation timed out after 10005 milliseconds with 0 bytes received
   ```
   
   After PR
   ```
   curl  --max-time 10 -X PUT 'http://adm:[email protected]:15984/mptest/short' -H 
'Content-Type: multipart/related;boundary="abc123"' --data-binary 
$'--abc123\r\nContent-Type: 
application/json\r\n\r\n{"_attachments":{"ohai":{"follows":true,"content_type":"text/plain","length":
 4}}}\r\n--abc123\r\n\r\noha\r\n--abc123--'
   {"error":"bad_request","reason":"attachment shorter than expected"}
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to