Skip to content

Commit

Permalink
service/s3/s3crypto Fix request retries
Browse files Browse the repository at this point in the history
Closing and removing the temp file after send causes retry requests to
fail with an error such as:

filestore: SerializationError: failed to prepare body for retry
caused by: SerializationError: failed to reset request body
caused by: SerializationError: failed to get next request body reader
caused by: seek /tmp/213721967: file already closed

I believe the Complete handler is guaranteed to be called finally
after retries attempts have succeeded or been exhausted.
  • Loading branch information
gwatts authored and jasdel committed Jul 20, 2020
1 parent dd92eb1 commit e7830bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion service/s3/s3crypto/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func getWriterStore(req *request.Request, path string, useTempFile bool) (io.Rea
return nil, err
}

req.Handlers.Send.PushBack(func(r *request.Request) {
req.Handlers.Complete.PushBack(func(r *request.Request) {
// Close the temp file and cleanup
f.Close()
os.Remove(f.Name())
Expand Down

0 comments on commit e7830bf

Please sign in to comment.