Michael Sica (Ataraxis Software)
2006-Aug-08 04:39 UTC
[Rails] File upload into Mysql (using lighttpd) problem
Hello All, I''ve run into a snag. (I apologize in advance. I''m not very good at system administration.) I''m building an app that allows users to upload files. Up until now I have been storing the files on the file system, but tonight I decided to change the app so the files are stored in the database as a longblob. I thought everything was working great, until I tried uploading a file that is almost 1 meg in size. I''ve got a bunch of test images I use, and the smaller ones (200k and below) work fine. But when I try the 700k & 900k files it just doesn''t work. (It did work when I was storing them on the file system.) I''ve done a bit of googling for an answer, but I haven''t found anything that looks like a solution. I''m using mysql 4.1. All my tables are InnoDB. I''m running lighttpd for the web server. There is something on this page about FastCGI not liking file sizes of a certain kind. (Very bottom) http://wiki.rubyonrails.org/rails/pages/HowtoUploadFiles It says to change the param, IPCCommTimeout, to a higher amount. But he''s using Apache, and I''m using lighttpd. (I don''t see the equivalent setting in the lighttpd.conf file. http://www.lighttpd.net/documentation/fastcgi.html#options) I tried changing the, "idle-timeout", to a really high number, but that didn''t work. BUT, like I said before, I wasn''t having problems before I switch to the DB style of storage. So I looked into DB-related issues. The closest thing I found was a recommendation to increase the "max_allowed_packet" param in mysql. I increased it to 52427776, but that didn''t fix the problem either. I really don''t know what else to look into. I''ve included what I''m seeing on the console when the problem occurs at the bottom of this post. Does anyone have any suggestions? Thanks! -michael. ------ (omitted a ton of binary text) bca3ca698c5345898e9c5444f8e2de5657a265206b528506a2a0575311c6831e55fb7fd8eb629e051b857f3a7d9fecf4c39f3873fc1cec05dc71e47f8855d9291f372e134f817eef4c954a94fa845c37996c56e45b91eec95ff00891a380a68f5f3aff2a7f83ad76ffc47d7f3d7fca9d0fbe2df1fdcbbfdeed0f0783f4ff0b87f89fdbf8ef6d7f79f69fe778be9d1ab9b5f8f6fff008d53e75fe5ebc38fcbf9f54a26ae2694f415afede1f3fe5d7fffd9'', ''f'', ''350zchromesilver.jpg'')): /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/abstract_adapter.rb:120:in `log'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/mysql_adapter.rb:185:in `execute'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/mysql_adapter.rb:195:in `insert'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/base.rb:1739:in `create_without_callbacks'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/callbacks.rb:261:in `create_without_timestamps'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/timestamp.rb:30:in `create'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/base.rb:1718:in `create_or_update_without_callbacks'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/callbacks.rb:249:in `create_or_update'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/base.rb:1392:in `save_without_validation'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/validations.rb:724:in `save_without_transactions'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/transactions.rb:126:in `save'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/transactions.rb:91:in `transaction'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/transactions.rb:118:in `transaction'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/transactions.rb:126:in `save'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/associations/has_many_association.rb:143:in `insert_record'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/callbacks.rb:343:in `callback'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/associations/association_proxy.rb:110:in `method_missing'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/associations/has_many_association.rb:90:in `method_missing'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/callbacks.rb:343:in `callback'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/callbacks.rb:335:in `callback'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/callbacks.rb:330:in `callback'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/callbacks.rb:262:in `create_without_timestamps'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/timestamp.rb:30:in `create'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/base.rb:1718:in `create_or_update_without_callbacks'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/callbacks.rb:249:in `create_or_update'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/base.rb:1392:in `save_without_validation'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/validations.rb:724:in `save_without_transactions'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/transactions.rb:126:in `save'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/transactions.rb:91:in `transaction'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/transactions.rb:118:in `transaction'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/transactions.rb:126:in `save'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/associations/has_many_association.rb:143:in `insert_record'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/associations/association_collection.rb:26:in `<<'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/associations/association_collection.rb:23:in `<<'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/transactions.rb:91:in `transaction'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/transactions.rb:118:in `transaction'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.1/lib/active_record/associations/association_collection.rb:22:in `<<'' /app/controllers/piece_controller.rb:62:in `new_piece'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in `perform_action_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in `process_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in `process_without_session_management_support'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in `process'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.1/lib/dispatcher.rb:38:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.1/lib/fcgi_handler.rb:150:in `process_request'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.1/lib/fcgi_handler.rb:54:in `process!'' /usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:600:in `each_cgi'' /usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:597:in `each_cgi'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.1/lib/fcgi_handler.rb:53:in `process!'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.1/lib/fcgi_handler.rb:23:in `process!'' public/dispatch.fcgi:24 -- Posted via http://www.ruby-forum.com/.
Michael Sica (Ataraxis Software)
2006-Aug-10 01:42 UTC
[Rails] Re: File upload into Mysql (using lighttpd) problem
Thank goodness for source control. I''m just going back to my file-based approach. No sense in wasting time trying to figure this out. -- Posted via http://www.ruby-forum.com/.