SQL database not showing. Ruby on rails - ruby-on-rails

I’m trying to bring Adopt a Hydrant to Helsinki.
So far I've managed to change the location of the map to Helsinki, build a database with postgreSQL, set the private key and deploy the app in heroku (the app is available at paloposti.herokuapp.com).
However no hydrants are showing in the map. I’ve replaced all the latitudes and longitutes in the seeds.rb file and run:
bundle exec rake db:create
bundle exec rake db:schema:load
rake db:setup
bundle exec rake db:seed
I’m sure I’m missing something very stupid, but what?
my logs :
2015-08-15T11:47:39.043348+00:00 app[web.1]: ORDER BY distance
2015-08-15T11:47:39.043351+00:00 app[web.1]: ):
2015-08-15T11:47:39.043353+00:00 app[web.1]: app/models/thing.rb:22:in `find_closest'
2015-08-15T11:47:39.043354+00:00 app[web.1]: app/controllers/things_controller.rb:5:in `show'
2015-08-15T11:47:39.043355+00:00 app[web.1]:
2015-08-15T11:47:39.043357+00:00 app[web.1]:
2015-08-15T11:50:07.856659+00:00 heroku[router]: at=info method=GET path="/things.json?utf8=%E2%9C%93&lat=60.180887&lng=24.94053800000006" host=paloposti.herokuapp.com request_id=568f316d-88c7-4fae-9d00-697994614ba9 fwd="82.214.17.63" dyno=web.1 connect=1ms service=6ms status=500 bytes=245
2015-08-15T11:50:07.848768+00:00 app[web.1]: Started GET "/things.json?utf8=%E2%9C%93&lat=60.180887&lng=24.94053800000006" for 82.214.17.63 at 2015-08-15 11:50:07 +0000
2015-08-15T11:50:07.850481+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "lat"=>"60.180887", "lng"=>"24.94053800000006"}
2015-08-15T11:50:07.852069+00:00 app[web.1]: Thing Load (0.8ms) SELECT *, (3959 * ACOS(COS(RADIANS(60.180887)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(24.94053800000006)) + SIN(RADIANS(60.180887)) * SIN(RADIANS(lat)))) AS distance
2015-08-15T11:50:07.852071+00:00 app[web.1]: FROM things
2015-08-15T11:50:07.852074+00:00 app[web.1]: LIMIT 10
2015-08-15T11:50:07.852076+00:00 app[web.1]:
2015-08-15T11:50:07.852109+00:00 app[web.1]: PG::UndefinedTable: ERROR: relation "things" does not exist
2015-08-15T11:50:07.852110+00:00 app[web.1]: LINE 2: FROM things
2015-08-15T11:50:07.852112+00:00 app[web.1]: ^
2015-08-15T11:50:07.852116+00:00 app[web.1]: FROM things
2015-08-15T11:50:07.852117+00:00 app[web.1]: ORDER BY distance
2015-08-15T11:50:07.852118+00:00 app[web.1]: LIMIT 10
2015-08-15T11:50:07.850436+00:00 app[web.1]: Processing by ThingsController#show as JSON
2015-08-15T11:50:07.852073+00:00 app[web.1]: ORDER BY distance
2015-08-15T11:50:07.852245+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.8ms)
2015-08-15T11:50:07.852115+00:00 app[web.1]: : SELECT *, (3959 * ACOS(COS(RADIANS(60.180887)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(24.94053800000006)) + SIN(RADIANS(60.180887)) * SIN(RADIANS(lat)))) AS distance
2015-08-15T11:50:07.852120+00:00 app[web.1]:
2015-08-15T11:50:07.853033+00:00 app[web.1]:
2015-08-15T11:50:07.853036+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "things" does not exist
2015-08-15T11:50:07.853038+00:00 app[web.1]: LINE 2: FROM things
2015-08-15T11:50:07.853039+00:00 app[web.1]: ^
2015-08-15T11:50:07.853040+00:00 app[web.1]: : SELECT *, (3959 * ACOS(COS(RADIANS(60.180887)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(24.94053800000006)) + SIN(RADIANS(60.180887)) * SIN(RADIANS(lat)))) AS distance
2015-08-15T11:50:07.853042+00:00 app[web.1]: FROM things
2015-08-15T11:50:07.853043+00:00 app[web.1]: ORDER BY distance
2015-08-15T11:50:07.853044+00:00 app[web.1]: LIMIT 10
2015-08-15T11:50:07.853046+00:00 app[web.1]: ):
2015-08-15T11:50:07.853047+00:00 app[web.1]: app/models/thing.rb:22:in `find_closest'
2015-08-15T11:50:07.853048+00:00 app[web.1]: app/controllers/things_controller.rb:5:in `show'
2015-08-15T11:50:07.853050+00:00 app[web.1]:
2015-08-15T11:50:07.853051+00:00 app[web.1]:
2015-08-15T11:50:12.578442+00:00 heroku[router]: at=info method=GET path="/things.json?utf8=%E2%9C%93&lat=60.180887&lng=24.94053800000006" host=paloposti.herokuapp.com request_id=03a40dd8-6fdd-4a34-8258-b37583c1d490 fwd="82.214.17.63" dyno=web.1 connect=1ms service=7ms status=500 bytes=245
2015-08-15T11:50:12.569835+00:00 app[web.1]: Started GET "/things.json?utf8=%E2%9C%93&lat=60.180887&lng=24.94053800000006" for 82.214.17.63 at 2015-08-15 11:50:12 +0000
2015-08-15T11:50:12.573575+00:00 app[web.1]: LINE 2: FROM things
2015-08-15T11:50:12.573578+00:00 app[web.1]: : SELECT *, (3959 * ACOS(COS(RADIANS(60.180887)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(24.94053800000006)) + SIN(RADIANS(60.180887)) * SIN(RADIANS(lat)))) AS distance
2015-08-15T11:50:12.573580+00:00 app[web.1]: FROM things
2015-08-15T11:50:12.573581+00:00 app[web.1]: ORDER BY distance
2015-08-15T11:50:12.573583+00:00 app[web.1]: LIMIT 10
2015-08-15T11:50:12.573536+00:00 app[web.1]: Thing Load (1.3ms) SELECT *, (3959 * ACOS(COS(RADIANS(60.180887)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(24.94053800000006)) + SIN(RADIANS(60.180887)) * SIN(RADIANS(lat)))) AS distance
2015-08-15T11:50:12.573584+00:00 app[web.1]:
2015-08-15T11:50:12.573542+00:00 app[web.1]: LIMIT 10
2015-08-15T11:50:12.573573+00:00 app[web.1]: PG::UndefinedTable: ERROR: relation "things" does not exist
2015-08-15T11:50:12.571510+00:00 app[web.1]: Processing by ThingsController#show as JSON
2015-08-15T11:50:12.574536+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "things" does not exist
2015-08-15T11:50:12.573540+00:00 app[web.1]: ORDER BY distance
2015-08-15T11:50:12.571537+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "lat"=>"60.180887", "lng"=>"24.94053800000006"}
2015-08-15T11:50:12.573543+00:00 app[web.1]:
2015-08-15T11:50:12.573709+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms (ActiveRecord: 1.3ms)
2015-08-15T11:50:12.574539+00:00 app[web.1]: ^
2015-08-15T11:50:12.574534+00:00 app[web.1]:
2015-08-15T11:50:12.574541+00:00 app[web.1]: : SELECT *, (3959 * ACOS(COS(RADIANS(60.180887)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(24.94053800000006)) + SIN(RADIANS(60.180887)) * SIN(RADIANS(lat)))) AS distance
2015-08-15T11:50:12.574538+00:00 app[web.1]: LINE 2: FROM things
2015-08-15T11:50:12.574542+00:00 app[web.1]: FROM things
2015-08-15T11:50:12.574543+00:00 app[web.1]: ORDER BY distance
2015-08-15T11:50:12.573576+00:00 app[web.1]: ^
2015-08-15T11:50:12.573539+00:00 app[web.1]: FROM things
2015-08-15T11:50:12.574545+00:00 app[web.1]: LIMIT 10
2015-08-15T11:50:12.574548+00:00 app[web.1]: app/models/thing.rb:22:in `find_closest'
2015-08-15T11:50:12.574546+00:00 app[web.1]: ):
2015-08-15T11:50:12.574550+00:00 app[web.1]:
2015-08-15T11:50:12.574551+00:00 app[web.1]:
2015-08-15T11:50:12.574549+00:00 app[web.1]: app/controllers/things_controller.rb:5:in `show'
2015-08-15T11:50:12.886199+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=paloposti.herokuapp.com request_id=0f37c35f-4795-453f-8f43-2b51fd0533f5 fwd="82.214.17.63" dyno=web.1 connect=4ms service=2ms status=200 bytes=736
2015-08-15T11:50:13.655695+00:00 app[web.1]: Started GET "/things.json?utf8=%E2%9C%93&lat=60.180887&lng=24.94053800000006" for 82.214.17.63 at 2015-08-15 11:50:13 +0000
2015-08-15T11:50:13.657311+00:00 app[web.1]: Processing by ThingsController#show as JSON
2015-08-15T11:50:13.657318+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "lat"=>"60.180887", "lng"=>"24.94053800000006"}
2015-08-15T11:50:13.659033+00:00 app[web.1]: Thing Load (1.0ms) SELECT *, (3959 * ACOS(COS(RADIANS(60.180887)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(24.94053800000006)) + SIN(RADIANS(60.180887)) * SIN(RADIANS(lat)))) AS distance
2015-08-15T11:50:13.659036+00:00 app[web.1]: FROM things
2015-08-15T11:50:13.659037+00:00 app[web.1]: ORDER BY distance
2015-08-15T11:50:13.659038+00:00 app[web.1]: LIMIT 10
2015-08-15T11:50:13.659040+00:00 app[web.1]:
2015-08-15T11:50:13.659066+00:00 app[web.1]: PG::UndefinedTable: ERROR: relation "things" does not exist
2015-08-15T11:50:13.659067+00:00 app[web.1]: LINE 2: FROM things
2015-08-15T11:50:13.659069+00:00 app[web.1]: ^
2015-08-15T11:50:13.659070+00:00 app[web.1]: : SELECT *, (3959 * ACOS(COS(RADIANS(60.180887)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(24.94053800000006)) + SIN(RADIANS(60.180887)) * SIN(RADIANS(lat)))) AS distance
2015-08-15T11:50:13.659072+00:00 app[web.1]: FROM things
2015-08-15T11:50:13.659073+00:00 app[web.1]: ORDER BY distance
2015-08-15T11:50:13.659075+00:00 app[web.1]: LIMIT 10
2015-08-15T11:50:13.659076+00:00 app[web.1]:
2015-08-15T11:50:13.659209+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms (ActiveRecord: 1.0ms)
2015-08-15T11:50:13.659999+00:00 app[web.1]:
2015-08-15T11:50:13.660004+00:00 app[web.1]: ^
2015-08-15T11:50:13.660006+00:00 app[web.1]: : SELECT *, (3959 * ACOS(COS(RADIANS(60.180887)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(24.94053800000006)) + SIN(RADIANS(60.180887)) * SIN(RADIANS(lat)))) AS distance
2015-08-15T11:50:13.660001+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "things" does not exist
2015-08-15T11:50:13.660003+00:00 app[web.1]: LINE 2: FROM things
2015-08-15T11:50:13.660007+00:00 app[web.1]: FROM things
2015-08-15T11:50:13.660009+00:00 app[web.1]: ORDER BY distance
2015-08-15T11:50:13.660011+00:00 app[web.1]: ):
2015-08-15T11:50:13.660010+00:00 app[web.1]: LIMIT 10
2015-08-15T11:50:13.660013+00:00 app[web.1]: app/models/thing.rb:22:in `find_closest'
2015-08-15T11:50:13.660015+00:00 app[web.1]: app/controllers/things_controller.rb:5:in `show'
2015-08-15T11:50:13.660016+00:00 app[web.1]:
2015-08-15T11:50:13.660017+00:00 app[web.1]:
2015-08-15T11:50:13.663608+00:00 heroku[router]: at=info method=GET path="/things.json?utf8=%E2%9C%93&lat=60.180887&lng=24.94053800000006" host=paloposti.herokuapp.com request_id=e523b244-725d-4671-82db-2555d0836704 fwd="82.214.17.63" dyno=web.1 connect=1ms service=6ms status=500 bytes=245
2015-08-15T11:50:13.876213+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=paloposti.herokuapp.com request_id=f81408cd-cdc4-4c6b-afda-a4d8633bf033 fwd="82.214.17.63" dyno=web.1 connect=1ms service=1ms status=200 bytes=736

When you run bundle exec rake db:seed. You are actually just running it on your local machine. So to seed to the database on heroku you would run heroku run rake db:seed.

Related

ActiveRecord::StatementInvalid in Orders::BuildController#update

Working with these models:
User.rb
class User < ApplicationRecord
has_many :quotes
end
Quote.rb
class Quote < ApplicationRecord
belongs_to :user
has_many :country_quotes, dependent: :delete_all
has_many :countries, through: :country_quotes, dependent: :delete_all
end
Country.rb
class Country < ApplicationRecord
has_many :country_quotes, dependent: :delete_all
has_many :quotes, through: :country_quotes, dependent: :delete_all
end
Country_Quote.rb
class CountryQuote < ApplicationRecord
belongs_to :country, dependent: :delete
belongs_to :quote, dependent: :delete
end
Via console, I can run this query and I get the result I'm looking for:
theresults = Quote.joins(:countries).where("countries.name = 'España'")
theresults.where(shippingtype: 'Urgente').first.cost
However when I try to run a similar query within build_controller.rb (it's a controller to handle my Wicked gem for the model Order) I get this error:
ActiveRecord::StatementInvalid in Orders::BuildController#update
PG::SyntaxError: ERROR: syntax error at or near "order" LINE 1: ...RE "quotes"."user_id" = $1 AND (countries.name = #order.coun... ^
class Orders::BuildController < ApplicationController
def update
temporderregularshippingprice = #user.quotes.joins(:countries).where("countries.name = #order.country" )
puts 'user.quotes2: ' + #user.quotes
puts 'order.country2: ' + #order.country
orderregularshippingprice = temporderregularshippingprice.where(shippingtype: 'Ordinario').first.cost # line returning the error
puts 'orderregularshippingprice: ' + orderregularshippingprice.to_s
...
end
end
According to the trace, #user.quotes and #order.country are correctly detected from that part of the code:
11:04:21 web.1 | ↳ app/controllers/orders/build_controller.rb:52:in `update'
11:04:21 web.1 | orderpriceperpage:
11:04:21 web.1 | **user.quotes2**: #<Quote::ActiveRecord_Associations_CollectionProxy:0x00000001132da8c0>
11:04:21 web.1 | **order.country2**: España
11:04:21 web.1 | Quote Load (0.6ms) SELECT "quotes".* FROM "quotes" INNER JOIN "country_quotes" ON "country_quotes"."quote_id" = "quotes"."id" INNER JOIN "countries" ON "countries"."id" = "country_quotes"."country_id" WHERE "quotes"."user_id" = $1 AND (countries.name = #order.country) AND "quotes"."shippingtype" = $2 ORDER BY "quotes"."id" ASC LIMIT $3 [["user_id", 2], ["shippingtype", "Ordinario"], ["LIMIT", 1]]
11:04:21 web.1 | ↳ app/controllers/orders/build_controller.rb:62:in `update'
11:04:21 web.1 | Completed 500 Internal Server Error in 43ms (ActiveRecord: 13.8ms | Allocations: 22630)
11:04:21 web.1 |
11:04:21 web.1 |
11:04:21 web.1 |
11:04:21 web.1 | ActiveRecord::StatementInvalid (PG::SyntaxError: ERROR: syntax error at or near "order"
11:04:21 web.1 | LINE 1: ...RE "quotes"."user_id" = $1 AND (countries.name = #order.coun...
11:04:21 web.1 | ^
11:04:21 web.1 | ):
11:04:21 web.1 |
You are using the variable in double quotes which is interpreted as string.
temporderregularshippingprice = #user.quotes.joins(:countries).where("countries.name = #order.country" )
Use this instead
temporderregularshippingprice = #user.quotes.joins(:countries).where("countries.name = ?", #order.country )
OR
temporderregularshippingprice = #user.quotes.joins(:countries).where(countries: { name: #order.country })

socket.io with iOS client connect Heroku

I really have a big trouble.
I setup socket.io with Node.js on Heroku(1X dyno * 2), and a iOS app use socket.io-client-swift to connect to Node.js server.
There are about 10-20 users connecting server.
In first 10 minutes connection, everything is ok. Afterwards, the connections start disconnecting and then connect. And they repeat (disconnect, connect, disconnect, connect, ...).
The logs are
2015-06-09T16:57:08.193803+00:00 heroku[router]: at=info method=GET path="/socket.io/?transport=polling&device_system_name=iPhone%20OS&locale=zh-Hant&token=fcc8f9de-731f-4e9f-8984-4ef66f35a017&device_system_version=8.1&app_version=1.0.4.26&device_model=iPhone&b64=1" host=test.mygood.com request_id=8b8334e1-4644-43a5-a68f-5374c7158ee5 fwd="58.115.190.26,103.22.201.247" dyno=web.2 connect=1ms service=9ms status=200 bytes=306
2015-06-09T16:57:08.200240+00:00 app[web.2]: token fcc8f9de-731f-4e9f-8984-4ef66f35a017
2015-06-09T16:57:08.231692+00:00 app[web.2]: shake
2015-06-09T16:57:08.231764+00:00 app[web.2]: loop 0
2015-06-09T16:57:08.244560+00:00 app[web.2]: notmatch: 652 75625
2015-06-09T16:57:08.244754+00:00 app[web.2]: loop 1
2015-06-09T16:57:08.257590+00:00 app[web.2]: notmatch: 668 24747
2015-06-09T16:57:08.229925+00:00 app[web.2]: has connected: qyUbFoTi7h9g31mFAAL4 { userId: 793 }
2015-06-09T16:57:08.261104+00:00 app[web.2]: loop 2
2015-06-09T16:57:08.393477+00:00 app[web.1]: 91BXJwsGY4hn6rWNAAKK has disconnected!
2015-06-09T16:56:51.814378+00:00 heroku[router]: at=info method=GET path="/socket.io/?transport=polling&device_system_name=iPhone%20OS&locale=zh-Hant&token=4b6606d4-b569-4eca-ae9d-10a567061c8c&device_system_version=8.3&app_version=1.0.4.26&device_model=iPhone&sid=YOfYOZ2khJ-6mcBnAALi&b64=1" host=test.mygood.com request_id=a11b31aa-1ffb-46de-9de1-305599b5a399 fwd="118.165.42.38,108.162.226.25" dyno=web.2 connect=1ms service=2ms status=400 bytes=228
2015-06-09T16:57:08.572700+00:00 app[web.2]: feTOjlhWmquYCEfjAAJ6 has disconnected!
2015-06-09T16:57:06.770212+00:00 heroku[router]: at=info method=GET path="/socket.io/?transport=websocket&device_system_name=iPhone%20OS&locale=zh-Hant&token=bd06e22e-7175-42ac-88f4-e6e68f449620&device_system_version=8.3&app_version=1.0.4.26&device_model=iPhone&sid=LzZEXe6cINwxDqb_AAMI" host=test.mygood.com request_id=82dc60be-c247-451a-a9e5-120720485620 fwd="27.247.203.209,103.22.200.134" dyno=web.2 connect=1ms service=4ms status=400 bytes=504
2015-06-09T16:57:08.609417+00:00 app[web.1]: shake
2015-06-09T16:57:08.609461+00:00 app[web.1]: loop 0
2015-06-09T16:57:08.968691+00:00 heroku[router]: at=info method=GET path="/socket.io/?transport=polling&device_system_name=iPhone%20OS&locale=zh-Hant&token=bd06e22e-7175-42ac-88f4-e6e68f449620&device_system_version=8.3&app_version=1.0.4.26&device_model=iPhone&b64=1" host=test.mygood.com request_id=84f68bc2-889d-4935-83af-be0ab81a4ce5 fwd="27.247.203.209,103.22.200.83" dyno=web.2 connect=2ms service=2ms status=200 bytes=306
2015-06-09T16:57:08.908175+00:00 heroku[router]: at=info method=GET path="/socket.io/?transport=polling&device_system_name=iPhone%20OS&locale=zh-Hant&token=afd16987-e2ea-446e-999f-e2f61aa0dde5&device_system_version=8.3&app_version=1.0.4.26&device_model=iPhone&b64=1" host=test.mygood.com request_id=e4def746-c8c2-4241-92f0-2236eda03dc3 fwd="223.137.154.167,103.22.200.105" dyno=web.1 connect=2ms service=3ms status=200 bytes=306
2015-06-09T16:57:08.908393+00:00 app[web.1]: token afd16987-e2ea-446e-999f-e2f61aa0dde5
2015-06-09T16:57:08.936892+00:00 app[web.1]: 0CR17CxuaLjrkyZ7AAKL has disconnected!
2015-06-09T16:57:08.922146+00:00 app[web.1]: has connected: 97mC_C_oBgL9j3bPAAMM { userId: 670 }
2015-06-09T16:57:09.094138+00:00 app[web.1]: ZgQnkM0NzTfd0QTgAAKM has disconnected!
2015-06-09T16:57:08.971702+00:00 app[web.2]: token bd06e22e-7175-42ac-88f4-e6e68f449620
2015-06-09T16:57:09.208419+00:00 app[web.2]: token fcc8f9de-731f-4e9f-8984-4ef66f35a017
2015-06-09T16:57:08.984120+00:00 app[web.2]: has connected: Jn9DJKjq5nsQbBxAAAL5 { userId: 652 }
2015-06-09T16:57:09.232017+00:00 app[web.2]: Qis91FslGt1xajvuAAJ7 has disconnected!
2015-06-09T16:57:09.239394+00:00 heroku[router]: at=info method=GET path="/socket.io/?transport=polling&device_system_name=iPhone%20OS&locale=zh-Hant&token=afd16987-e2ea-446e-999f-e2f61aa0dde5&device_system_version=8.3&app_version=1.0.4.26&device_model=iPhone&sid=97mC_C_oBgL9j3bPAAMM&b64=1" host=test.mygood.com request_id=c0c378d9-d836-4afe-b32b-a097037d65c0 fwd="223.137.154.167,103.22.200.105" dyno=web.1 connect=1ms service=2ms status=200 bytes=208
2015-06-09T16:57:09.236929+00:00 app[web.2]: has connected: v2zsDiJGUT3jMdLXAAL6 { userId: 793 }
The app.js file
var io = require('socket.io')(process.env.PORT || 3001);
io.use(function (socket, next){
var token = socket.request._query.token;
authorize(token, function(user) {
.... // some authorization work
next();
}, function(error){
next(new Error('API Token wrong'));
});
});
io.on('connection', function (socket) {
console.log('has connected:', socket.id, socket.api);
socket.on('disconnect', function () {
console.log(socket.id + ' has disconnected!');
});
});

How can a deadlock occur when no row or table locks are set? (caused by rails ActiveRecord#touch)

I'm using Rails 4's template-caching features extensively. Lots of nested templates and touch: true on lots of models. Overall it has proven to be a comprehensive solution that is easy to reason about.
I recently implemented a feature where multiple background jobs are created which iterate through hundreds of objects and create other objects in relation to them. When each of these objects is created, the same user is touched.
So, these two jobs run in parallel:
job A: serially creates hundreds of objects, each time touching User 123
job B: serially creates hundreds of objects, each time touching User 123
Upon deploying this feature, I discovered that sometimes postgres detects a deadlock and cancels two queries which are waiting for one another. The query shown in the error is always the touch query (update User 123's updated_at with the current time).
pid: 33541 tid: 0 vtid: LOG: database system was shut down at 2014-03-27 19:57:11 EDT
pid: 33545 tid: 0 vtid: LOG: autovacuum launcher started
pid: 33539 tid: 0 vtid: LOG: database system is ready to accept connections
pid: 33626 tid: 0 vtid: 2/5 LOG: statement: set client_encoding to 'UTF8'
pid: 33626 tid: 0 vtid: 2/6 LOG: statement: set client_encoding to 'unicode'
pid: 33626 tid: 0 vtid: 2/7 LOG: statement: SET client_min_messages TO 'warning'
pid: 33626 tid: 0 vtid: 2/8 LOG: statement: SHOW client_min_messages
pid: 33626 tid: 0 vtid: 2/9 LOG: statement: SET client_min_messages TO 'panic'
pid: 33626 tid: 0 vtid: 2/10 LOG: statement: SET standard_conforming_strings = on
pid: 33626 tid: 0 vtid: 2/11 LOG: statement: SET client_min_messages TO 'warning'
pid: 33626 tid: 0 vtid: 2/12 LOG: statement: SET time zone 'UTC'
pid: 33626 tid: 0 vtid: 2/13 LOG: statement: SELECT oid, typname, typelem, typdelim, typinput FROM pg_type
pid: 33626 tid: 0 vtid: 2/14 LOG: statement: SHOW TIME ZONE
pid: 33626 tid: 0 vtid: 2/15 LOG: statement: SELECT 1
pid: 33626 tid: 0 vtid: 2/16 LOG: statement: SELECT COUNT(*)
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind in ('v','r')
AND c.relname = 'users'
AND n.nspname = ANY (current_schemas(false))
pid: 33626 tid: 0 vtid: 2/17 LOG: statement: SELECT attr.attname
FROM pg_attribute attr
INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1]
WHERE cons.contype = 'p'
AND cons.conrelid = '"users"'::regclass
pid: 33626 tid: 0 vtid: 2/18 LOG: statement: SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
pid: 33626 tid: 0 vtid: 2/19 LOG: statement: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
pid: 33627 tid: 0 vtid: 3/2 LOG: statement: set client_encoding to 'UTF8'
pid: 33627 tid: 0 vtid: 3/3 LOG: statement: set client_encoding to 'unicode'
pid: 33627 tid: 0 vtid: 3/4 LOG: statement: SET client_min_messages TO 'warning'
pid: 33627 tid: 0 vtid: 3/5 LOG: statement: SHOW client_min_messages
pid: 33627 tid: 0 vtid: 3/6 LOG: statement: SET client_min_messages TO 'panic'
pid: 33627 tid: 0 vtid: 3/7 LOG: statement: SET standard_conforming_strings = on
pid: 33627 tid: 0 vtid: 3/8 LOG: statement: SET client_min_messages TO 'warning'
pid: 33627 tid: 0 vtid: 3/9 LOG: statement: SET time zone 'UTC'
pid: 33627 tid: 0 vtid: 3/10 LOG: statement: SELECT oid, typname, typelem, typdelim, typinput FROM pg_type
pid: 33627 tid: 0 vtid: 3/11 LOG: statement: SHOW TIME ZONE
pid: 33627 tid: 0 vtid: 3/12 LOG: statement: SELECT 1
pid: 33627 tid: 0 vtid: 3/13 LOG: statement: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
pid: 33627 tid: 0 vtid: 3/14 LOG: statement: SELECT COUNT(*)
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind in ('v','r')
AND c.relname = 'users'
AND n.nspname = ANY (current_schemas(false))
pid: 33627 tid: 0 vtid: 3/15 LOG: statement: SELECT attr.attname
FROM pg_attribute attr
INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1]
WHERE cons.contype = 'p'
AND cons.conrelid = '"users"'::regclass
pid: 33627 tid: 0 vtid: 3/16 LOG: statement: SELECT id FROM "users" WHERE (bared_at IS NOT NULL) ORDER BY "users"."id" ASC LIMIT 1000
pid: 33628 tid: 0 vtid: 4/2 LOG: statement: set client_encoding to 'UTF8'
pid: 33628 tid: 0 vtid: 4/3 LOG: statement: set client_encoding to 'unicode'
pid: 33628 tid: 0 vtid: 4/4 LOG: statement: SET client_min_messages TO 'warning'
pid: 33628 tid: 0 vtid: 4/5 LOG: statement: SHOW client_min_messages
pid: 33628 tid: 0 vtid: 4/6 LOG: statement: SET client_min_messages TO 'panic'
pid: 33628 tid: 0 vtid: 4/7 LOG: statement: SET standard_conforming_strings = on
pid: 33628 tid: 0 vtid: 4/8 LOG: statement: SET client_min_messages TO 'warning'
pid: 33628 tid: 0 vtid: 4/9 LOG: statement: SET time zone 'UTC'
pid: 33628 tid: 0 vtid: 4/10 LOG: statement: SELECT oid, typname, typelem, typdelim, typinput FROM pg_type
pid: 33628 tid: 0 vtid: 4/11 LOG: statement: SHOW TIME ZONE
pid: 33628 tid: 0 vtid: 4/12 LOG: statement: SELECT 1
pid: 33628 tid: 0 vtid: 4/13 LOG: statement: SELECT id FROM "users" WHERE (bared_at IS NOT NULL) ORDER BY "users"."id" ASC LIMIT 1000
pid: 33627 tid: 0 vtid: 3/17 LOG: statement: SELECT COUNT(*)
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind in ('v','r')
AND c.relname = 'monkeys'
AND n.nspname = ANY (current_schemas(false))
pid: 33628 tid: 0 vtid: 4/14 LOG: statement: SELECT COUNT(*)
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind in ('v','r')
AND c.relname = 'monkeys'
AND n.nspname = ANY (current_schemas(false))
pid: 33627 tid: 0 vtid: 3/18 LOG: statement: SELECT attr.attname
FROM pg_attribute attr
INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1]
WHERE cons.contype = 'p'
AND cons.conrelid = '"monkeys"'::regclass
pid: 33628 tid: 0 vtid: 4/15 LOG: statement: SELECT attr.attname
FROM pg_attribute attr
INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1]
WHERE cons.contype = 'p'
AND cons.conrelid = '"monkeys"'::regclass
pid: 33627 tid: 0 vtid: 3/19 LOG: statement: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users_monkeys"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
pid: 33628 tid: 0 vtid: 4/16 LOG: statement: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users_monkeys"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
pid: 33627 tid: 0 vtid: 3/20 LOG: statement: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"monkeys"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
pid: 33628 tid: 0 vtid: 4/17 LOG: statement: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"monkeys"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
pid: 33627 tid: 0 vtid: 3/21 LOG: statement: SHOW search_path
pid: 33628 tid: 0 vtid: 4/18 LOG: statement: SHOW search_path
pid: 33627 tid: 0 vtid: 3/23 LOG: execute a1: SELECT COUNT(*) FROM "monkeys" INNER JOIN "users_monkeys" ON "monkeys"."id" = "users_monkeys"."monkey_id" WHERE "users_monkeys"."user_id" = $1 AND (((monkeys.name = 'recruiter') AND (monkeys.resource_type IS NULL) AND (monkeys.resource_id IS NULL)))
pid: 33627 tid: 0 vtid: 3/23 DETAIL: parameters: $1 = '2'
pid: 33628 tid: 0 vtid: 4/20 LOG: execute a1: SELECT COUNT(*) FROM "monkeys" INNER JOIN "users_monkeys" ON "monkeys"."id" = "users_monkeys"."monkey_id" WHERE "users_monkeys"."user_id" = $1 AND (((monkeys.name = 'recruiter') AND (monkeys.resource_type IS NULL) AND (monkeys.resource_id IS NULL)))
pid: 33628 tid: 0 vtid: 4/20 DETAIL: parameters: $1 = '2'
pid: 33627 tid: 0 vtid: 3/24 LOG: statement: SELECT "foos".* FROM "foos" WHERE "foos"."user_id" = 2 AND "foos"."fooer_id" = 1 LIMIT 1
pid: 33628 tid: 0 vtid: 4/21 LOG: statement: SELECT "foos".* FROM "foos" WHERE "foos"."user_id" = 1 AND "foos"."fooer_id" = 2 LIMIT 1
pid: 33628 tid: 0 vtid: 4/22 LOG: statement: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"foos"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
pid: 33627 tid: 0 vtid: 3/25 LOG: statement: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"foos"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
pid: 33628 tid: 0 vtid: 4/23 LOG: statement: SELECT COUNT(*)
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind in ('v','r')
AND c.relname = 'foos'
AND n.nspname = ANY (current_schemas(false))
pid: 33627 tid: 0 vtid: 3/26 LOG: statement: SELECT COUNT(*)
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind in ('v','r')
AND c.relname = 'foos'
AND n.nspname = ANY (current_schemas(false))
pid: 33628 tid: 0 vtid: 4/24 LOG: statement: SELECT attr.attname
FROM pg_attribute attr
INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1]
WHERE cons.contype = 'p'
AND cons.conrelid = '"foos"'::regclass
pid: 33627 tid: 0 vtid: 3/27 LOG: statement: SELECT attr.attname
FROM pg_attribute attr
INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1]
WHERE cons.contype = 'p'
AND cons.conrelid = '"foos"'::regclass
pid: 33628 tid: 0 vtid: 4/25 LOG: statement: BEGIN
pid: 33627 tid: 0 vtid: 3/28 LOG: statement: BEGIN
pid: 33628 tid: 0 vtid: 4/25 LOG: statement: SELECT 1 AS one FROM "foos" WHERE ("foos"."user_id" = 1 AND "foos"."id" != 4 AND "foos"."fooer_id" = 2) LIMIT 1
pid: 33627 tid: 0 vtid: 3/28 LOG: statement: SELECT 1 AS one FROM "foos" WHERE ("foos"."user_id" = 2 AND "foos"."id" != 3 AND "foos"."fooer_id" = 1) LIMIT 1
pid: 33628 tid: 0 vtid: 4/25 LOG: statement: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
pid: 33627 tid: 0 vtid: 3/28 LOG: execute a2: SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1
pid: 33627 tid: 0 vtid: 3/28 DETAIL: parameters: $1 = '2'
pid: 33627 tid: 0 vtid: 3/28 LOG: statement: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.619282' WHERE "users"."id" = 2
pid: 33628 tid: 0 vtid: 4/25 LOG: execute a2: SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1
pid: 33628 tid: 0 vtid: 4/25 DETAIL: parameters: $1 = '1'
pid: 33627 tid: 6723 vtid: 3/28 LOG: execute a2: SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1
pid: 33627 tid: 6723 vtid: 3/28 DETAIL: parameters: $1 = '1'
pid: 33628 tid: 0 vtid: 4/25 LOG: statement: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.627175' WHERE "users"."id" = 1
pid: 33627 tid: 6723 vtid: 3/28 LOG: statement: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.628983' WHERE "users"."id" = 1
pid: 33628 tid: 6724 vtid: 4/25 LOG: execute a2: SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1
pid: 33628 tid: 6724 vtid: 4/25 DETAIL: parameters: $1 = '2'
pid: 33628 tid: 6724 vtid: 4/25 LOG: statement: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.632111' WHERE "users"."id" = 2
pid: 33627 tid: 6723 vtid: 3/28 ERROR: deadlock detected
pid: 33627 tid: 6723 vtid: 3/28 DETAIL: Process 33627 waits for ShareLock on transaction 6724; blocked by process 33628.
Process 33628 waits for ShareLock on transaction 6723; blocked by process 33627.
Process 33627: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.628983' WHERE "users"."id" = 1
Process 33628: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.632111' WHERE "users"."id" = 2
I am surprised that this deadlock occurs, because neither the row nor the table are being locked. Shouldn't the second transaction simply wait for the first to finish?
update: minimal sql-only reproduction of bug here: https://gist.github.com/jjb/9823023
Your original log was incomplete, because the first UPDATEs didn't have a transaction ID, so they weren't included in the original log.
Now that the log with virtual txids is there, you can see that PostgreSQL is behaving exactly as designed.
The relevant lines are:
pid: 33627 tid: 0 vtid: 3/28 LOG: statement: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.619282' WHERE "users"."id" = 2
pid: 33628 tid: 0 vtid: 4/25 LOG: statement: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.627175' WHERE "users"."id" = 1
pid: 33627 tid: 6723 vtid: 3/28 LOG: statement: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.628983' WHERE "users"."id" = 1
pid: 33628 tid: 6724 vtid: 4/25 LOG: statement: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.632111' WHERE "users"."id" = 2
pid: 33627 tid: 6723 vtid: 3/28 ERROR: deadlock detected
pid: 33627 tid: 6723 vtid: 3/28 DETAIL: Process 33627 waits for ShareLock on transaction 6724; blocked by process 33628.
Process 33628 waits for ShareLock on transaction 6723; blocked by process 33627.
Process 33627: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.628983' WHERE "users"."id" = 1
Process 33628: UPDATE "users" SET "updated_at" = '2014-03-27 23:58:02.632111' WHERE "users"."id" = 2
Here:
3/28 locks id=2 for update
4/25 locks id=1 for update
3/28 attempts to lock id=1 for update, blocking on the lock held by 4/25
4/25 attempts to lock id=2 for update, blocking on the lock held by 3/28
At this point neither transaction can make progress, so PostgreSQL aborts one of them.
To prevent this from happening, your application must ensure that it always acquires locks in the same order. Where that is not possible, it must try to only work with one dependent object in any given transaction, so ordering issues cannot arise. Or it must be prepared to handle deadlocks by trapping the exception and re-issuing the transaction.
To learn more, see Explicit locking in the manual.

Give a 404 instead of a 500 error for missing templates

I have a Rails 3.0 app (working on a 3.2 upgrade) and whenever someone requests a template that doesn't exist it gives a 500 error in production. For instance mysite.com/blog_posts/532 sends the post with ID 532 back as HTML no problem, but if for some reason mysite.com/blog_posts/532.txt is requested, the app raises a 500 ActionView::MissingTemplate error.
This shouldn't happen, because the template shouldn't be there in the first place. It should more properly be a 404 error, or perhaps just show the HTML template.
How can I make the app either show a 404 error for all missing-template errors, or show the default HTML template instead of giving a 500?
Log:
Started GET "/blog_posts/73.txt" for 127.0.0.1 at 2013-05-20 21:22:51 -0400
Processing by BlogPostsController#show as TEXT
Parameters: {"id"=>"73"}
PK and serial sequence (2.0ms) SELECT attr.attname, seq.relname
FROM pg_class seq,
pg_attribute attr,
pg_depend dep,
pg_namespace name,
pg_constraint cons
WHERE seq.oid = dep.objid
AND seq.relkind = 'S'
AND attr.attrelid = dep.refobjid
AND attr.attnum = dep.refobjsubid
AND attr.attrelid = cons.conrelid
AND attr.attnum = cons.conkey[1]
AND cons.contype = 'p'
AND dep.refobjid = '"blog_posts_blog_tags"'::regclass
PK and custom sequence (1.0ms) SELECT attr.attname,
CASE
WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN
substr(split_part(def.adsrc, '''', 2),
strpos(split_part(def.adsrc, '''', 2), '.')+1)
ELSE split_part(def.adsrc, '''', 2)
END
FROM pg_class t
JOIN pg_attribute attr ON (t.oid = attrelid)
JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum)
JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1])
WHERE t.oid = '"blog_posts_blog_tags"'::regclass
AND cons.contype = 'p'
AND def.adsrc ~* 'nextval'
BlogPost Load (0.0ms) SELECT "blog_posts".* FROM "blog_posts" WHERE "blog_posts"."id" = '73' LIMIT 1
SQL (0.0ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"blog_posts"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Completed 500 Internal Server Error in 59ms
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
SQL (1.0ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
ActionView::MissingTemplate (Missing template blog_posts/show with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:text], :lo
cale=>[:en, :en]} in view paths "C:/Rails/myapp/app/views", "C:/Ruby/lib/ruby/gems/1.9.1/gems/devise-1.5.4/app/views"):
Rendered C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within res
cues/layout (1.0ms)
Updated log, with trace:
Started GET "/blog_posts/73.txt" for 127.0.0.1 at 2013-05-20 22:14:28 -0400
Processing by BlogPostsController#show as TEXT
Parameters: {"id"=>"73"}
PK and serial sequence (2.0ms) SELECT attr.attname, seq.relname
FROM pg_class seq,
pg_attribute attr,
pg_depend dep,
pg_namespace name,
pg_constraint cons
WHERE seq.oid = dep.objid
AND seq.relkind = 'S'
AND attr.attrelid = dep.refobjid
AND attr.attnum = dep.refobjsubid
AND attr.attrelid = cons.conrelid
AND attr.attnum = cons.conkey[1]
AND cons.contype = 'p'
AND dep.refobjid = '"blog_posts_blog_tags"'::regclass
PK and custom sequence (1.0ms) SELECT attr.attname,
CASE
WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN
substr(split_part(def.adsrc, '''', 2),
strpos(split_part(def.adsrc, '''', 2), '.')+1)
ELSE split_part(def.adsrc, '''', 2)
END
FROM pg_class t
JOIN pg_attribute attr ON (t.oid = attrelid)
JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum)
JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1])
WHERE t.oid = '"blog_posts_blog_tags"'::regclass
AND cons.contype = 'p'
AND def.adsrc ~* 'nextval'
BlogPost Load (0.0ms) SELECT "blog_posts".* FROM "blog_posts" WHERE "blog_posts"."id" = '73' LIMIT 1
SQL (0.0ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"blog_posts"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
--------------------------------------------------------------------------------
exception: Missing template blog_posts/show with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:text], :locale=>[:en, :en]} in view paths "C:/Rails/myapp/app/views", "C:/Ruby/lib/ruby/gems/1.9.1/gems/devise-1.5.4/app/views"
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_view/paths.rb:15:in `find'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_view/lookup_context.rb:81:in `find'
C:in `find_template'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_view/render/rendering.rb:46:in `_determine_template'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_view/render/rendering.rb:24:in `render'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/abstract_controller/rendering.rb:115:in `_render_template'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/abstract_controller/rendering.rb:109:in `render_to_body'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/renderers.rb:47:in `render_to_body'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/abstract_controller/rendering.rb:102:in `render_to_string'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/abstract_controller/rendering.rb:93:in `render'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/rendering.rb:17:in `render'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.20/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
C:/Ruby/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.20/lib/active_support/core_ext/benchmark.rb:5:in `ms'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/instrumentation.rb:39:in `render'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/abstract_controller/base.rb:150:in `process_action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/rendering.rb:11:in `process_action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.20/lib/active_support/callbacks.rb:436:in `_run__326851374__process_action__856302785__callbacks'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.20/lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.20/lib/active_support/callbacks.rb:94:in `run_callbacks'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/abstract_controller/callbacks.rb:17:in `process_action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/rescue.rb:17:in `process_action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.20/lib/active_support/notifications.rb:52:in `block in instrument'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.20/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.20/lib/active_support/notifications.rb:52:in `instrument'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.6.2.96/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:38:in `block in process_action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.6.2.96/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:318:in `perform_action_with_newrelic_trace'
C:/Ruby/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.6.2.96/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:37:in `process_action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/abstract_controller/base.rb:119:in `process'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/abstract_controller/rendering.rb:41:in `process'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal.rb:138:in `dispatch'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_controller/metal.rb:178:in `block in action'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/routing/route_set.rb:68:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/routing/route_set.rb:68:in `dispatch'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/routing/route_set.rb:33:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-mount-0.6.14/lib/rack/mount/route_set.rb:148:in `block in call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:93:in `block in recognize'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:89:in `optimized_each'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:92:in `recognize'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-mount-0.6.14/lib/rack/mount/route_set.rb:139:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/routing/route_set.rb:499:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.6.2.96/lib/new_relic/rack/error_collector.rb:12:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.6.2.96/lib/new_relic/rack/agent_hooks.rb:18:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.6.2.96/lib/new_relic/rack/developer_mode.rb:28:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch'
C:/Ruby/lib/ruby/gems/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/head.rb:14:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.2.7/lib/rack/methodoverride.rb:24:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/flash.rb:182:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/cookies.rb:302:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/query_cache.rb:32:in `block in call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/query_cache.rb:12:in `cache'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/query_cache.rb:31:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.20/lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.20/lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/callbacks.rb:44:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.2.7/lib/rack/sendfile.rb:106:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.20/lib/rails/rack/logger.rb:13:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.2.7/lib/rack/runtime.rb:17:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.20/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.2.7/lib/rack/lock.rb:13:in `block in call'
<internal:prelude>:10:in `synchronize'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.2.7/lib/rack/lock.rb:13:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/actionpack-3.0.20/lib/action_dispatch/middleware/static.rb:30:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/airbrake-3.1.4/lib/airbrake/rack.rb:41:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/airbrake-3.1.4/lib/airbrake/user_informer.rb:12:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.20/lib/rails/application.rb:168:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.20/lib/rails/application.rb:77:in `method_missing'
C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.20/lib/rails/rack/log_tailer.rb:14:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.2.7/lib/rack/content_length.rb:13:in `call'
C:/Ruby/lib/ruby/gems/1.9.1/gems/rack-1.2.7/lib/rack/handler/webrick.rb:52:in `service'
C:/Ruby/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
C:/Ruby/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
C:/Ruby/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
--------------------------------------------------------------------------------
Completed 200 OK in 59ms
[2013-05-20 22:14:28] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked
= true
in your applicationController you can should be able to rescue from the missing template, and then re raise a 404 .
class ApplicationController > ActionController::Base
rescue_from ActionView::MissingTemplate do |exception|
raise ActionController::RoutingError.new('Not Found')
end
end

Infamous 'byte sequence" error with local install of gitorious on Ruby 1.9.1

I am trying to install gitorious on my personal server but I am not very familiar with Ruby or the frameworks and scripts involved in getting to the finish line.
I am following the following instructions to install gitorious on my CentOS 5.4 server:
http://www.tikalk.com/alm/blog/installing-gitorious-centos-55
The site comes up but as soon as I click on the login link I get the 500 error screen and an exception report is emailed to me. The error is reported as an "invalid byte sequence" and google tells me that it's related to Ruby 1.9. From what I've read, gitorious.org is using 1.9 and others got it working, so now I'm curious as to why it's not working on my system.
Judging from the backtrace, it looks like the invalid encoding might be coming from the database which is a MySQL 5.0.77 in my case. All tables in the gitorious database have their DEFAULT_CHARSET set to utf8.
You can make out the version of most components that I have installed from the stack. I have rails 3.0.0 installed. If anything else would be useful, please comment and I'll reply.
The exception report goes like this:
A ArgumentError occurred in sessions#new:
invalid byte sequence in US-ASCII
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/template_error.rb:43:in `split'
-------------------------------
Request:
-------------------------------
* URL : http://[my-server]/login
* IP address: [my-ip]
* Parameters: {"controller"=>"sessions", "action"=>"new"}
* Rails root: /opt/gitorious/gitorious
-------------------------------
Session:
-------------------------------
* session id: nil
* data: nil
-------------------------------
Environment:
-------------------------------
* DOCUMENT_ROOT : /var/www/gitorious/public
* HTTP_ACCEPT : application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
* HTTP_ACCEPT_ENCODING : gzip, deflate
* HTTP_ACCEPT_LANGUAGE : en-us
* HTTP_CONNECTION : keep-alive
* HTTP_COOKIE : _gitorious_sess=1a4c10ada66c96f213d6f4573d35286c
* HTTP_HOST : [my-hostname]
* HTTP_REFERER : http://[my-hostname]/
* HTTP_USER_AGENT : Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7
* PATH_INFO : /login
* QUERY_STRING :
* REMOTE_ADDR : [my-ip]
* REMOTE_PORT : 53586
* REQUEST_METHOD : GET
* REQUEST_URI : /login
* SCRIPT_NAME :
* SCRIPT_URI : http://[my-server]/login
* SCRIPT_URL : /login
* SERVER_ADDR : [client-ip]
* SERVER_ADMIN : root#localhost
* SERVER_NAME : [my-hostname]
* SERVER_PORT : 80
* SERVER_PROTOCOL : HTTP/1.1
* SERVER_SOFTWARE : Apache/2.2.3 (CentOS)
* _ : _
* action_controller.request.path_parameters : {"controller"=>"sessions", "action"=>"new"}
* action_controller.request.query_parameters : {}
* action_controller.request.request_parameters: {}
* action_controller.rescue.request : #
* action_controller.rescue.response : #
* rack.errors : #
* rack.input : #
* rack.multiprocess : true
* rack.multithread : false
* rack.request.cookie_hash : {"_gitorious_sess"=>"1a4c10ada66c96f213d6f4573d35286c"}
* rack.request.cookie_string : _gitorious_sess=1a4c10ada66c96f213d6f4573d35286c
* rack.request.query_hash : {}
* rack.request.query_string :
* rack.run_once : false
* rack.session : {}
* rack.session.options : {:key=>"_gitorious_sess", :path=>"/", :domain=>".", :expire_after=>21 days, :secure=>false, :httponly=>true, :cookie_only=>true, :secret=>"dopFactAnArcyirUckryfsObNohokOrOmFeinwojUpbofIamcicyesicCulfaydd", :id=>"1a4c10ada66c96f213d6f4573d35286c"}
* rack.session.record : #
* rack.url_scheme : http
* rack.version : [1, 0]
* Process: 22046
* Server : [my-server]
-------------------------------
Backtrace:
-------------------------------
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/template_error.rb:43:in `split'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/template_error.rb:43:in `source_extract'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/template_error.rb:86:in `compute_backtrace'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/template_error.rb:11:in `initialize'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/template.rb:212:in `new'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/template.rb:212:in `rescue in render_template'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/template.rb:205:in `render_template'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/base.rb:265:in `render'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/base.rb:348:in `_render_with_layout'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_view/base.rb:262:in `render'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:1250:in `render_for_file'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:945:in `render'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `block in render_with_benchmark'
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
/usr/local/ruby/ruby191/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render_with_benchmark'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:1326:in `default_render'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:1332:in `perform_action'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_with_filters'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `block in perform_action_with_benchmark'
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
/usr/local/ruby/ruby191/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:17:in `ms'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_with_benchmark'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/rescue.rb:160:in `perform_action_with_rescue'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/flash.rb:146:in `perform_action_with_flash'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:532:in `process'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_with_filters'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:391:in `process'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:386:in `call'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:437:in `call'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:87:in `dispatch'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:121:in `_call'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:130:in `block in build_middleware_stack'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/string_coercion.rb:25:in `call'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/string_coercion.rb:25:in `call'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in `call'
[RAILS_ROOT]/vendor/rails/railties/lib/rails/rack/metal.rb:47:in `call'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb:122:in `call'
[RAILS_ROOT]/vendor/rails/activerecord/lib/active_record/query_cache.rb:29:in `block in call'
[RAILS_ROOT]/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
[RAILS_ROOT]/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in `cache'
[RAILS_ROOT]/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in `call'
[RAILS_ROOT]/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in `call'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/rack-1.0.1/lib/rack/lock.rb:11:in `block in call'
:8:in `synchronize'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:in `call'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:441:in `start_request_handler'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:381:in `block in handle_spawn_application'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/utils.rb:252:in `safe_fork'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:377:in `handle_spawn_application'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:163:in `start'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:222:in `start'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rails_application'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:247:in `block in spawn_rails_application'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:80:in `block in synchronize'
:8:in `synchronize'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rails_application'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:145:in `spawn_application'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:278:in `handle_spawn_application'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
/usr/local/ruby/ruby191/lib/ruby/gems/1.9.1/gems/passenger-2.2.15/bin/passenger-spawn-server:61:in `'
In this post by Marius Mårnes Mathiesen, he recommends removing the i18n gem. Maybe that solves your problem.

Resources