xl: CreateFile shouldn't prematurely timeout (#11878)

For large objects taking more than '3 minutes' response
times in a single PUT operation can timeout prematurely
as 'ResponseHeader' timeout hits for 3 minutes. Avoid
this by keeping the connection active during CreateFile
phase.
This commit is contained in:
Harshavardhana 2021-03-24 09:05:03 -07:00 committed by GitHub
parent 21cfc4aa49
commit 79564656eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -337,7 +337,12 @@ func (client *storageRESTClient) CreateFile(ctx context.Context, volume, path st
values.Set(storageRESTFilePath, path) values.Set(storageRESTFilePath, path)
values.Set(storageRESTLength, strconv.Itoa(int(size))) values.Set(storageRESTLength, strconv.Itoa(int(size)))
respBody, err := client.call(ctx, storageRESTMethodCreateFile, values, ioutil.NopCloser(reader), size) respBody, err := client.call(ctx, storageRESTMethodCreateFile, values, ioutil.NopCloser(reader), size)
defer http.DrainBody(respBody) if err != nil {
return err
}
waitReader, err := waitForHTTPResponse(respBody)
defer http.DrainBody(ioutil.NopCloser(waitReader))
defer respBody.Close()
return err return err
} }

View File

@ -287,10 +287,9 @@ func (s *storageRESTServer) CreateFileHandler(w http.ResponseWriter, r *http.Req
s.writeErrorResponse(w, err) s.writeErrorResponse(w, err)
return return
} }
err = s.storage.CreateFile(r.Context(), volume, filePath, int64(fileSize), r.Body)
if err != nil { done := keepHTTPResponseAlive(w)
s.writeErrorResponse(w, err) done(s.storage.CreateFile(r.Context(), volume, filePath, int64(fileSize), r.Body))
}
} }
// DeleteVersion delete updated metadata. // DeleteVersion delete updated metadata.