Exception RuntimeError in Passenger RequestHandler's client socket (can't modify string; temporarily locked) - ruby-on-rails

Receiving below error on rails application hosted on nginx:
Sending 502 response: application did not send a complete response
App 1462 stderr: [ 2015-xx-xx 15:10:29.2082 1494/XXXXXXXXXXXX(Worker 1) utils.rb:85 ]: *** Exception RuntimeError in Passenger RequestHandler's client socket (can't modify string; temporarily locked) (process 1494, thread XXXXXXXXXXXXX(Worker 1)):
App 1462 stderr: from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-5.0.13/lib/phusion_passenger/utils/unseekable_socket.rb:188:in `read'
App 1462 stderr: from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-5.0.13/lib/phusion_passenger/utils/unseekable_socket.rb:188:in `read'
[ 2015-09-09 15:10:29.2083 1423/7fa8af7fe700 age/Cor/Req/Utils.cpp:95 ]: [Client 6-19] Sending 502 response: application did not send a complete response
App 1462 stderr: from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-5.0.13/lib/phusion_passenger/message_channel.rb:177:in `read_scalar'
App 1462 stderr: from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-5.0.13/lib/phusion_passenger/request_handler/thread_handler.rb:217:in `parse_session_request'
App 1462 stderr: from /usr/local/lib/ruby/gems/1.9.1/gems/passenger
Restarted VM and application but receiving same error.

Not sure what exactly causes this error. But as can be found from this link:
http://code.google.com/p/phusion-passenger/issues/detail?id=582
We reuse the same buffer over and over for receiving request data, for performance reasons. If your app is somehow able to use our buffer for receiving I/O data as well, in a different thread, then that would result in a race condition with the reporter error as a result.
One user reports resolution of similar problem here:
http://code.google.com/p/phusion-passenger/issues/detail?id=605
Indeed, I've narrowed it down to rails-master and/or rack-cache 1.0. When removing caching from latest version of rails (so it does not load rack-cache) everything works.
Hope it will be helpful

Related

Installed another Rails application on server and existing application stop working

I got below error when install another rails application on server.
App 970 stderr: Cannot execute "/home/ec2-user/.rvm/gems/ruby-2.3.0/gems/passenger-5.1.2/buildout/support-binaries/PassengerAgent": Permission denied (errno=13)
[ 2017-04-19 14:25:36.2735 898/7f6d6a5e4700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /var/www/html/entertainoz: An error occurred while starting up the preloader.
Error ID: 7312b405
Error details saved to: /tmp/passenger-error-S9HJRx.html
Message from application: Cannot execute "/home/ec2-user/.rvm/gems/ruby-2.3.0/gems/passenger-5.1.2/buildout/support-binaries/PassengerAgent": Permission denied (errno=13)
I tried to find the issue but still not get it.

Failed to upgrade the iOS application while app is doing network operations using sockets

When I am trying to update the application using iTunes, I am getting a error pop-up - Unable to download application.
I am running into this error only when my app is doing network operations using sockets.
In other scenarios where app is either not running or is idle, it works correctly.
From the console logs, I got following error message -
2013-04-18 10:11:39 AM GMT+07:00 backboardd <Warning>: pid_suspend failed for [7104]: Unknown error: -1, Unknown error: -1
2013-04-18 10:11:39 AM GMT+07:00 backboardd <Warning>: Could not set priority of [7104] to 4096, priority: No such process
2013-04-18 10:11:39 AM GMT+07:00 backboardd <Warning>: Application 'UIKitApplication:com.avaya.AVSIPiPhoneCFE[0xe6ed]' exited abnormally with signal 9: Killed: 9
Any idea why this would happen?
This question addresses a similar problem.
In short, iOS automatically restarts an app that crashes or exits abnormally, if it has a background execution flag set. It seems that this leads to iTunes being unable to overwrite the old binary with the new one, because it's still running.

Apache with passenger gives error(Premature end of script headers) in development mode

I'm using Apache + passenger for my rails application, The application is running fine in production mode except when the browser displays error message after every 2-3 clicks in development mode which goes off when i refresh the page.I'm using metal in my rails application which i see could be the reason but not sure if it is the only reason.
Error message on browser:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.16 (Ubuntu) Server at localhost Port 80
Apache log Error:
[Thu Dec 01 16:55:23 2011] [error] [client 127.0.0.1] Premature end of script headers: view_transactions, referer: http://localhost/admin_portal/1014978061/view_transactions
[ pid=660 thr=3078097552 file=ext/apache2/Hooks.cpp:822 time=2011-12-01 16:55:23.563 ]: The backend application (process 796) did not send a valid HTTP response; instead, it sent nothing at all. It is possible that it has crashed; please check whether there are crashing bugs in this application.
[ pid=796 thr=-608495398 file=utils.rb:176 time=2011-12-01 11:25:23.878 ]: *** Exception NoMethodError in application (undefined method `new' for Rails:Module) (process 796, thread #<Thread:0xb77631b4>):
from /home/brijendra/aptana_studio_3_workspace/wantsa/vendor/plugins/newrelic_rpm/lib/new_relic/control.rb:467:in `new_instance'
from /home/brijendra/aptana_studio_3_workspace/wantsa/vendor/plugins/newrelic_rpm/lib/new_relic/control.rb:54:in `instance'
from /home/brijendra/aptana_studio_3_workspace/wantsa/vendor/plugins/newrelic_rpm/lib/new_relic/agent.rb:167:in `logger'
I would be eager to post any other output if required and also suggestions to fix this issue.
I fixed this error by changing cache as true in my development.rb and it worked fine.

Rails app may be crashing passenger, not sure how to debug?

My app generates some image data on the fly and sends it back to the browser with send_data some_huge_blob, :type => 'image/png'. This works well enough in development mode, but in production with nginx/passenger in the mix it appears as if sometimes passenger just crashes. Here is the debug output in my nginx log
[ pid=596 thr=140172782794496 file=ext/common/ApplicationPool/Pool.h:1162 time=2011-07-25 23:15:14.965 ]: Exception occurred while connecting to checked out process 1428: Cannot connect to Unix socket '/tmp/passenger.1.0.589/generation-0/backends/ruby.kJRjXYuZteKoogZIufN8a2cDPdpbIlYmIr1hh3G9UV7GhKDB4pqZ5y0jR': Connection refused (111)
[ pid=596 thr=140172782794496 file=ext/common/ApplicationPool/Pool.h:685 time=2011-07-25 23:15:14.965 ]: Detaching process 1428
[ pid=596 thr=140172782794496 file=ext/common/ApplicationPool/../Process.h:138 time=2011-07-25 23:15:14.969 ]: Application process 1428 (0x2676ee0): destroyed.
[ pid=1405 thr=70178806733240 file=abstract_request_handler.rb:466 time=2011-07-25 23:15:14.982 ]: Accepting new request on main socket
2011/07/25 23:15:16 [error] 642#0: *96 upstream prematurely closed connection while reading response header from upstream, client: 173.8.216.57, server: app.somedomain.com, request: "GET /projects/4e2dee4c106a821bf2000008/revisions/1/assets/Layout2.psd/preview HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "app.somedomain.com"
Note that there is nothing in my production.log file that indicates the request even makes it to the app!
Any ideas? Or ideas as to how to debug this further? The connection refused bit is interesting...
For what it's worth, this is an Ubuntu image on a micro instance in AWS.

Nginx + Passenger - Uncaught exception in PassengerServer client thread

I've installed Passenger with Nginx for testing here and I keep getting this error after some thousand requests:
[ pid=57259 thr=0x40f07780 file=ext/nginx/HelperAgent.cpp:576 time=2010-12-15 14:04:25.876 ]: Uncaught exception in PassengerServer client thread:
exception: write() failed: Socket is not connected (57)
backtrace:
in 'void Client::forwardResponse(Passenger::SessionPtr&, Passenger::FileDescriptor&)' (HelperAgent.cpp:368)
in 'void Client::handleRequest(Passenger::FileDescriptor&)' (HelperAgent.cpp:502)
in 'void Client::threadMain()' (HelperAgent.cpp:595)
[ pid=57259 thr=0x40f07080 file=ext/nginx/HelperAgent.cpp:566 time=2010-12-15 14:04:26.416 ]: Couldn't forward the HTTP response back to the HTTP client: It seems the user clicked on the 'Stop' button in his browser.
I have 2 servers, and I was running haproxy+apache+mongrel on them, I switched one of them for haproxy+nginx+passenger (haproxy is only a backup for my testing, so I can redirect to the old schema quickly in case of fire).
So I noticed that my passenger dies after this message.
Im using ruby-ee 1.8.7, rails 2.3.5 and FreeBSD.
That turns out to be a FreeBSD kernel bug. We're slowly putting more workarounds in the Phusion Passenger codebase to work around this.

Resources