Forum: Ruby on Rails "EINVAL" Crashing with Instant Rails and PostgreSQL on Windo

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7f4d868adb4a96f10e7a92532ee9985f?d=identicon&s=25 Jeff Casimir (Guest)
on 2005-12-13 15:59
(Received via mailing list)
Hey all,

I was getting some similar crashes when using webbrick with high (a few
request every second or so) load so I moved up to Apache.  Specifically,
I am using the "InstantRails" package with Apache/SCGI and PostgreSQL
instead of mySQL.  However the same problem has sprung up again and
causes the server to spawn hundreds of separate ruby.exe processes.  Is
the below stack trace meaningful to anyone?  I don't _think_ this is a
problem with my app, it looks like a crash in the postgres module.
Thoughts?

Thanks,
Jeff

Production.log paste:

Processing PagesController#index (for 212.95.252.16 at 2005-12-13
09:47:10) [GET]
  Parameters: {"action"=>"index", "controller"=>"pages"}


Errno::EINVAL (Invalid argument):

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:86:in
`write'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:86:in
`<<'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:86:in
`query'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/postgres-compat.rb:33:in
`query'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/connection_adapters/postgresql_adapter.rb:63:in
`active?'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/connection_adapters/abstract/connection_specification.rb:103:in
`retrieve_connection'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/connection_adapters/abstract/connection_specification.rb:20:in
`connection'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/base.rb:931:in
`add_limit!'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/base.rb:924:in
`construct_finder_sql'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/base.rb:395:in
`find'
    /app/models/article.rb:6:in `find_most_recent'
    /app/controllers/pages_controller.rb:6:in `index'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/base.rb:853:in
`send'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/base.rb:853:in
`perform_action_without_filters'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/benchmarking.rb:69:in
`measure'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/rescue.rb:82:in
`perform_action'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/base.rb:369:in
`send'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/base.rb:369:in
`process_without_session_management_support'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/session_management.rb:116:in
`process'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/rails-0.14.4.3279/lib/dispatcher.rb:38:in
`dispatch'
    C:/ruby/irails/ruby/bin/scgi_service:23:in `process_request'
    C:/ruby/irails/ruby/bin/scgi_service:21:in `synchronize'
    C:/ruby/irails/ruby/bin/scgi_service:21:in `process_request'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:291:in
`read_header'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:253:in
`handle_client'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:234:in
`initialize'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:234:in `new'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:234:in
`handle_client'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:188:in `listen'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:186:in
`initialize'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:186:in `new'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:186:in `listen'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:412:in `run'
    C:/ruby/irails/ruby/bin/scgi_service:61




Processing PagesController#index (for 70.108.248.226 at 2005-12-13
09:47:28) [GET]
  Parameters: {"action"=>"index", "controller"=>"pages"}


Errno::EINVAL (Invalid argument):

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:86:in
`write'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:86:in
`<<'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:86:in
`query'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/postgres-compat.rb:33:in
`query'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/connection_adapters/postgresql_adapter.rb:63:in
`active?'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/connection_adapters/abstract/connection_specification.rb:103:in
`retrieve_connection'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/connection_adapters/abstract/connection_specification.rb:20:in
`connection'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/base.rb:931:in
`add_limit!'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/base.rb:924:in
`construct_finder_sql'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1.3279/lib/active_record/base.rb:395:in
`find'
    /app/models/article.rb:6:in `find_most_recent'
    /app/controllers/pages_controller.rb:6:in `index'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/base.rb:853:in
`send'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/base.rb:853:in
`perform_action_without_filters'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/benchmarking.rb:69:in
`measure'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/rescue.rb:82:in
`perform_action'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/base.rb:369:in
`send'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/base.rb:369:in
`process_without_session_management_support'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.1.3279/lib/action_controller/session_management.rb:116:in
`process'

C:/ruby/irails/ruby/lib/ruby/gems/1.8/gems/rails-0.14.4.3279/lib/dispatcher.rb:38:in
`dispatch'
    C:/ruby/irails/ruby/bin/scgi_service:23:in `process_request'
    C:/ruby/irails/ruby/bin/scgi_service:21:in `synchronize'
    C:/ruby/irails/ruby/bin/scgi_service:21:in `process_request'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:291:in
`read_header'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:253:in
`handle_client'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:234:in
`initialize'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:234:in `new'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:234:in
`handle_client'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:188:in `listen'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:186:in
`initialize'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:186:in `new'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:186:in `listen'
    C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:412:in `run'
    C:/ruby/irails/ruby/bin/scgi_service:61
8c43ed7f065406bf171c0f3eb32cf615?d=identicon&s=25 Zed A. Shaw (Guest)
on 2005-12-14 04:05
(Received via mailing list)
Hey Jeff,

That actually looks like the socket being used has become invalid.  The
man page on my Linux box says:

EINVAL fd is attached to an object which is unsuitable for
writing;  or the  file  was  opened  with  the  O_DIRECT flag, and
either the address specified in buf, the value specified in count,  or
the current file offset is not suitably aligned.

So that means your connection is getting closed or aborted in the
middle of a write operation.  Not sure if this helps though on Win32.

Zed

On Tue, 13 Dec 2005 09:58:20 -0500
7f4d868adb4a96f10e7a92532ee9985f?d=identicon&s=25 Jeff Casimir (Guest)
on 2005-12-14 12:35
(Received via mailing list)
Zed,

Thanks for the tip.  I think I am going to try switching from the "pure
ruby" postgres-pr driver to the C-based driver (which I've never used)
and see what happens.  If I track anything down relating to SCGI I'll
let you know.

Thanks,
Jeff
7f4d868adb4a96f10e7a92532ee9985f?d=identicon&s=25 Jeff Casimir (Guest)
on 2005-12-16 17:54
(Received via mailing list)
Zed,

I've found a little more info about this "EINVAL" crashes I'm having.
 From scgi.log:

[ERR][508] C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:259:in
`close'
C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:205:in `join'
C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:205:in
`collect_thread'
C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:181:in `listen'
C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:179:in `initialize'
C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:179:in `new'
C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:179:in `listen'
C:/ruby/irails/ruby/lib/ruby/site_ruby/1.8/scgi.rb:412:in `run'
C:/ruby/irails/ruby/bin/scgi_service:61

I have that repeated many times.  The consequence is that the server
spawns new ruby processes until it chokes.

Any thoughts?  Can I give you more information of any kind?

-Jeff
This topic is locked and can not be replied to.