Ask for Help
“S3 is giving us 400 timeout responses on every first upload for a request. All subsequent uploads for the same request seem to work fine.”
This turned out to be a bug in the HEAD version of Paperclip. They added a fingerprint method that creates a MD5 hash out of the original file, but the method forgets to rewind the original file when done. So S3 times out while waiting for data, but then rewinds the file before trying again. So it does ultimately get uploaded, but it was leading to ~10 second delays in the middle of the request.
Interesting Things
- Be careful when doing MyModel.find_by_column-that-is-a-string in ActiveRecord. If you pass it an integer it won’t do a type conversion and will pass it down to SQL as an unquoted integer. MySQL will then not use any indexes you have on that column. This is with Rails 2.3.x and MySQL 5.0.x