openfarmcc / OpenFarm

A free and open database for farming and gardening knowledge. You can grow anything!
https://OpenFarm.cc
MIT License
1.56k stars 240 forks source link

Blank search causes site to crash #741

Open roryaronson opened 8 years ago

roryaronson commented 8 years ago

Go to the homepage and click the search button without entering a search term and the site will crash. Or click this link: https://openfarm.cc/crop_search/?q=

simonv3 commented 8 years ago

This is probably related #732.

TheChirpyWitch commented 8 years ago

Hey. The page just refreshes if I do a blank search. How is it different?

TanSA05 commented 8 years ago

@TheChirpyWitch I think @simonv3 and I discussed this before. This is like an on and off issue, appears for some. Simon suggested we get back to this later in time.

simonv3 commented 8 years ago

@TheChirpyWitch Interesting!

A couple of things I'm wondering: when you do a blank search were you logged in? Do you get a difference between a logged in search and a not logged in search?

When I just accessed the link directly (from Rory's initial post) I see a 500 error (we should make that page much prettier). From the e-mail that I get sent every time a 500 error happens I see this:

A Rack::Timeout::RequestTimeoutException occurred in crop_searches#search:

  Request waited 0ms, then ran for longer than 15000ms
  app/models/guide.rb:149:in `compatibility_score'

-------------------------------
Request:
-------------------------------

  * URL        : https://openfarm.cc/crop_search?q=
  * HTTP Method: GET
  * IP address : 64.186.123.40
  * Parameters : {"q"=>"", "controller"=>"crop_searches", "action"=>"search"}
  * Timestamp  : 2016-08-05 17:40:04 UTC
  * Server : edc04c24-a961-4c35-bf80-6717a0fea8be
  * Rails root : /app
  * Process: 3

-------------------------------
Session:
-------------------------------

  * session id: [FILTERED]
  * data: #<ActionDispatch::Request::Session:0x007f0cdade5358 ...>

-------------------------------
Environment:
-------------------------------

  * GATEWAY_INTERFACE                              : CGI/1.2
  * HTTP_ACCEPT                                    : text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  * HTTP_ACCEPT_ENCODING                           : gzip, deflate, sdch, br
  * HTTP_ACCEPT_LANGUAGE                           : en-US,en;q=0.8,nl;q=0.6
  * HTTP_CONNECTION                                : close
  * HTTP_CONNECT_TIME                              : 3
  * HTTP_COOKIE                                    : _OpenFarm_session=TXptdWdBTWVXSlhLekJZZXJWTlZJS3hVa3kzbFRFUllUOUZ0RlIzWURpditYSVlGWWxOMmFHekQ2Z1M3NXA5TVhUaGFPUkw3RkphTFUrS3ZtdDhJMTBPM0k4RDVqWTN2alJrSStMc2pFNi9ZSXhaNUlJdnhIcEtlZzlNYnNacDRJRmk1VmlxcmVGSjhwWjJ3QlhQVTF5Y0NQZ0ppSjRhK09DUU8xWGpkQXczUUswdHZOd2F2NGFRYTFHeWhUei9tei9OVHJxdXY2ZHdkSHZaejVIMlJBWGdXcFBXMWxSMlJjYlE5NmRKM1NxTmZrU0czODFoY0ZKODZwUnZnTTBhQlRMb2lKV1RKaG5zZTN4alRlSlZRdVd6S2pkZ3o4cklwRDQyZlVvNlhYOSsveitjdTNLQVN3T1RCV2V4SjJGTTdsSGNtd0FtY0oralpURnhWeHVYRUNnbFRERWVuNDN0OVIrbXVYZjBmbkJPYUowK0s4dmNsSlFsaWxXVWNEdmozNS8rL2VjV1paMkl5Z1JHcFVTM0xPK0ZmcktWMm5oclJaU1MyakZmOExjQlE5R1pwdnBEQlZCMEsrYkxBWmoyQy0tMEZCU2xQd1l4QmlOaTYzckgzLzJDUT09--a544071af0ee649eb6f1907c5454933f274b4d52
  * HTTP_DNT                                       : 1
  * HTTP_HOST                                      : openfarm.cc
  * HTTP_ORIGIN                                    : 
  * HTTP_REFERER                                   : https://github.com/openfarmcc/OpenFarm/issues/741
  * HTTP_TOTAL_ROUTE_TIME                          : 0
  * HTTP_UPGRADE_INSECURE_REQUESTS                 : 1
  * HTTP_USER_AGENT                                : Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36
  * HTTP_VERSION                                   : HTTP/1.1
  * HTTP_VIA                                       : 1.1 vegur
  * HTTP_X_FORWARDED_FOR                           : 64.186.123.40
  * HTTP_X_FORWARDED_PORT                          : 443
  * HTTP_X_FORWARDED_PROTO                         : https
  * HTTP_X_REQUEST_ID                              : bc4dc5c0-efe6-422d-82aa-638e976f2638
  * HTTP_X_REQUEST_START                           : 1470418789748
  * ORIGINAL_FULLPATH                              : /crop_search/?q=
  * ORIGINAL_SCRIPT_NAME                           : 
  * PATH_INFO                                      : /crop_search
  * QUERY_STRING                                   : q=
  * REMOTE_ADDR                                    : 10.178.230.6
  * REQUEST_METHOD                                 : GET
  * REQUEST_PATH                                   : /crop_search/
  * REQUEST_URI                                    : /crop_search/?q=
  * ROUTES_69846552347280_SCRIPT_NAME              : 
  * SCRIPT_NAME                                    : 
  * SERVER_NAME                                    : openfarm.cc
  * SERVER_PORT                                    : 80
  * SERVER_PROTOCOL                                : HTTP/1.1
  * SERVER_SOFTWARE                                : thin 1.6.3 codename Protein Powder
  * action_controller.instance                     : #<CropSearchesController:0x007f0cdae03420>
  * action_dispatch.backtrace_cleaner              : #<Rails::BacktraceCleaner:0x007f0cd7e5eeb8>
  * action_dispatch.cookies                        : #<ActionDispatch::Cookies::CookieJar:0x007f0cdae01170>
  * action_dispatch.cookies_serializer             : 
  * action_dispatch.encrypted_cookie_salt          : encrypted cookie
  * action_dispatch.encrypted_signed_cookie_salt   : signed encrypted cookie
  * action_dispatch.http_auth_salt                 : http authentication
  * action_dispatch.key_generator                  : #<ActiveSupport::CachingKeyGenerator:0x007f0cd7e5e8c8>
  * action_dispatch.logger                         : #<Logger:0x007f0cd5a8a3c0>
  * action_dispatch.parameter_filter               : [:password]
  * action_dispatch.redirect_filter                : []
  * action_dispatch.remote_ip                      : 64.186.123.40
  * action_dispatch.request.content_type           : 
  * action_dispatch.request.formats                : [#<Mime::Type:0x007f0cd3c3b6f8 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html">]
  * action_dispatch.request.parameters             : {"q"=>"", "controller"=>"crop_searches", "action"=>"search"}
  * action_dispatch.request.path_parameters        : {:controller=>"crop_searches", :action=>"search"}
  * action_dispatch.request.query_parameters       : {"q"=>""}
  * action_dispatch.request.request_parameters     : {}
  * action_dispatch.request.unsigned_session_cookie: {"session_id"=>"957fb20f70c98e9f9a6f988b0a7593bd", "warden.user.user.key"=>[[BSON::ObjectId('53fdea2a6639300002020000')], "$2a$10$SIPXytGHVJXZwaR5IOHYgO"], "_csrf_token"=>"teSobnVyRyl0VcKSRI/9mdK33JaPtY+LTWabkFFHLRY=", "announcement_hide_time"=>2016-06-15 01:18:52 UTC}
  * action_dispatch.request_id                     : bc4dc5c0-efe6-422d-82aa-638e976f2638
  * action_dispatch.routes                         : #<ActionDispatch::Routing::RouteSet:0x007f0cd5e20520>
  * action_dispatch.secret_key_base                : 9a2bfa66386c5ba78c543bc6410072bac89433debea7ea2c969264d9e1b18ef3d3deec8c7b7237c9f2f4c47eef10d0a848b3f4097e3ad516c4faf8c7c2cfab8e
  * action_dispatch.secret_token                   : 
  * action_dispatch.show_detailed_exceptions       : false
  * action_dispatch.show_exceptions                : true
  * action_dispatch.signed_cookie_salt             : signed cookie
  * async.callback                                 : #<Method: Thin::Connection#post_process>
  * async.close                                    : #<EventMachine::DefaultDeferrable:0x007f0cdade7568>
  * rack-timeout.info                              : #<struct Rack::Timeout::RequestDetails id="bc4dc5c0-efe6-422d-82aa-638e976f2638", wait=0, service=15.000491792001412, timeout=15, state=:timed_out>
  * rack.attack.throttle_data                      : {"req/ip"=>{:count=>1, :period=>300, :limit=>300}}
  * rack.cors                                      : #<Rack::Cors::Result:0x007f0cdade71d0>
  * rack.errors                                    : #<IO:0x007f0cd2ce5550>
  * rack.input                                     : #<StringIO:0x007f0cdb3080d8>
  * rack.multiprocess                              : false
  * rack.multithread                               : false
  * rack.request.cookie_hash                       : {"_OpenFarm_session"=>"TXptdWdBTWVXSlhLekJZZXJWTlZJS3hVa3kzbFRFUllUOUZ0RlIzWURpditYSVlGWWxOMmFHekQ2Z1M3NXA5TVhUaGFPUkw3RkphTFUrS3ZtdDhJMTBPM0k4RDVqWTN2alJrSStMc2pFNi9ZSXhaNUlJdnhIcEtlZzlNYnNacDRJRmk1VmlxcmVGSjhwWjJ3QlhQVTF5Y0NQZ0ppSjRhK09DUU8xWGpkQXczUUswdHZOd2F2NGFRYTFHeWhUei9tei9OVHJxdXY2ZHdkSHZaejVIMlJBWGdXcFBXMWxSMlJjYlE5NmRKM1NxTmZrU0czODFoY0ZKODZwUnZnTTBhQlRMb2lKV1RKaG5zZTN4alRlSlZRdVd6S2pkZ3o4cklwRDQyZlVvNlhYOSsveitjdTNLQVN3T1RCV2V4SjJGTTdsSGNtd0FtY0oralpURnhWeHVYRUNnbFRERWVuNDN0OVIrbXVYZjBmbkJPYUowK0s4dmNsSlFsaWxXVWNEdmozNS8rL2VjV1paMkl5Z1JHcFVTM0xPK0ZmcktWMm5oclJaU1MyakZmOExjQlE5R1pwdnBEQlZCMEsrYkxBWmoyQy0tMEZCU2xQd1l4QmlOaTYzckgzLzJDUT09--a544071af0ee649eb6f1907c5454933f274b4d52"}
  * rack.request.cookie_string                     : _OpenFarm_session=TXptdWdBTWVXSlhLekJZZXJWTlZJS3hVa3kzbFRFUllUOUZ0RlIzWURpditYSVlGWWxOMmFHekQ2Z1M3NXA5TVhUaGFPUkw3RkphTFUrS3ZtdDhJMTBPM0k4RDVqWTN2alJrSStMc2pFNi9ZSXhaNUlJdnhIcEtlZzlNYnNacDRJRmk1VmlxcmVGSjhwWjJ3QlhQVTF5Y0NQZ0ppSjRhK09DUU8xWGpkQXczUUswdHZOd2F2NGFRYTFHeWhUei9tei9OVHJxdXY2ZHdkSHZaejVIMlJBWGdXcFBXMWxSMlJjYlE5NmRKM1NxTmZrU0czODFoY0ZKODZwUnZnTTBhQlRMb2lKV1RKaG5zZTN4alRlSlZRdVd6S2pkZ3o4cklwRDQyZlVvNlhYOSsveitjdTNLQVN3T1RCV2V4SjJGTTdsSGNtd0FtY0oralpURnhWeHVYRUNnbFRERWVuNDN0OVIrbXVYZjBmbkJPYUowK0s4dmNsSlFsaWxXVWNEdmozNS8rL2VjV1paMkl5Z1JHcFVTM0xPK0ZmcktWMm5oclJaU1MyakZmOExjQlE5R1pwdnBEQlZCMEsrYkxBWmoyQy0tMEZCU2xQd1l4QmlOaTYzckgzLzJDUT09--a544071af0ee649eb6f1907c5454933f274b4d52
  * rack.request.query_hash                        : {"q"=>""}
  * rack.request.query_string                      : q=
  * rack.run_once                                  : false
  * rack.session                                   : #<ActionDispatch::Request::Session:0x007f0cdade5358>
  * rack.session.options                           : #<ActionDispatch::Request::Session::Options:0x007f0cdade5308>
  * rack.url_scheme                                : http
  * rack.version                                   : [1, 0]
  * warden                                         : Warden::Proxy:69846594168520 @config={:default_scope=>:user, :scope_defaults=>{}, :default_strategies=>{:user=>[:rememberable, :database_authenticatable]}, :intercept_401=>false, :failure_app=>#<Devise::Delegator:0x007f0cd9139d30>}

-------------------------------
Backtrace:
-------------------------------

  app/models/guide.rb:149:in `compatibility_score'
  app/controllers/crop_searches_controller.rb:33:in `block in sort_guides'
  app/models/guide_search.rb:52:in `sort_by'
  app/models/guide_search.rb:52:in `method_missing'
  app/controllers/crop_searches_controller.rb:31:in `sort_guides'
  app/controllers/crop_searches_controller.rb:22:in `search'

Basically, it's taking too long to calculate the results, specifically in the compatibility score. We should fix this. It's definitely related to #767.

TheChirpyWitch commented 8 years ago

It seems to be working the same whether I am logged in or not. I tried opening @roryaronson 's link directly and still the page simply refreshes.

simonv3 commented 8 years ago

@TheChirpyWitch what do you mean by "page simply refreshes"? Does it go to the search page, or does it go to the home page?

TheChirpyWitch commented 8 years ago

The home page as well as the search page refreshes if I do a blank search.

simonv3 commented 8 years ago

Do you mean when you click on "search" on the home page without any text in the text input field, it takes you back to the home page? Or does it take you to the search page? It should take you to the search page, and that might be a different bug.