"EINVAL" Crashing with Instant Rails and PostgreSQL on Windo


#1

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:infind_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:inprocess_request’
C:/ruby/irails/ruby/bin/scgi_service:21:in synchronize' C:/ruby/irails/ruby/bin/scgi_service:21:inprocess_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:inhandle_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:innew’
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:inlisten’
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:innew’
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:inrun’
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:infind_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:inprocess_request’
C:/ruby/irails/ruby/bin/scgi_service:21:in synchronize' C:/ruby/irails/ruby/bin/scgi_service:21:inprocess_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:inhandle_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:innew’
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:inlisten’
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:innew’
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:inrun’
C:/ruby/irails/ruby/bin/scgi_service:61


#2

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


#3

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


#4

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:injoin’
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:inlisten’
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:innew’
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:inrun’
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