Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Nathan Witmer
RE: uncaught throw 'Fetch error' [ reply ]  
2007-11-21 15:46
No, you're right, it's an entirely contrived example. I'm just trying to find a reliable way of causing the same error that I'm getting randomly.

For the moment, disabling dynamic code reloading (and thus constant reconnects) on the staging instance has mitigated the problem for now.

The reason rails' development is causing reconnects is because of this pattern I'm using for multiple connections to different databases:

class Ref::BaseRecord < ActiveRecord::Base
self.abstract_class = true
establish_connection "ref_#{RAILS_ENV}"
end

I'll do some more digging today, but unfortunately I'm finding it difficult to reproduce...

Thanks.

By: Alex Pitigoi
RE: uncaught throw 'Fetch error' [ reply ]  
2007-11-20 23:58
Nathan, I'm not sure I follow that "queries in a loop and forcing a disconnect" scenario, nor do I understand its value. That sounds pretty much like expected behavior, as far as I can tell, and I can only hope there are no 2 threads playing that kind of Russian roulette with each other. I wonder how does the Rails environment manage to spawn a thread that would cause a forced disconnect on a connection in use.

Looking forward for some way to consistently recreate Rails app behavior in this sense. Thanks.

By: Nathan Witmer
RE: uncaught throw 'Fetch error' [ reply ]  
2007-11-20 21:07
I'll have to get back to you re: the CLI trace, but I was able to check the APPLHEAPSZ, it's 2048.

This isn't the only error message I've been seeing, just the most recent. I was able to reproduce this other error:

NameError: uncaught throw `Column information cannot be retrieved: '
from /home/nwitmer/ods_etl/vendor/plugins/ibm_db/lib/active_record/connection_adapters/ibm_db_adapter.rb:1192:in `fetch_assoc'
from /home/nwitmer/ods_etl/vendor/plugins/ibm_db/lib/active_record/connection_adapters/ibm_db_adapter.rb:1192:in `select_all'
from /home/nwitmer/ods_etl/vendor/plugins/ibm_db/lib/active_record/connection_adapters/ibm_db_adapter.rb:479:in `select_all'
from /home/nwitmer/ods_etl/vendor/rails/activerecord/lib/active_record/base.rb:447:in `find_by_sql'
from /home/nwitmer/ods_etl/vendor/rails/activerecord/lib/active_record/base.rb:1035:in `find_every'
from /home/nwitmer/ods_etl/vendor/rails/activerecord/lib/active_record/base.rb:438:in `find'
from /home/nwitmer/ods_etl/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb:66:in `find'
from /home/nwitmer/ods_etl/app/models/ref/xref_catalog.rb:53:in `search'
from (irb):5
from (irb):5:in `times'
from (irb):5


by running queries in a loop and forcing a disconnect (connection.disconnect!) from another thread after a short sleep. The same error seems to crop up in a loop: forcing a reconnect before an AR find, over and over -- it usually shows up within a couple hundred iterations. Rails' development mode code reloading was doing much the same thing with my models, although it was equally inconsistent.

Thanks for your assistance thus far, I'll look into the CLI tracing next.

By: Alex Pitigoi
RE: uncaught throw 'Fetch error' [ reply ]  
2007-11-20 20:17
Hi Nathan,

The first thing to check when dealing with unexpected behavior and missing relevant error codes is the CLI trace (as long as you can recreate the problem from time to time):
$ db2 UPDATE CLI CFG FOR SECTION COMMON USING Trace 1
$ db2 UPDATE CLI CFG FOR SECTION COMMON USING TracePathName <path>
$ db2 UPDATE CLI CFG FOR SECTION COMMON USING TraceComm 1
$ db2 UPDATE CLI CFG FOR SECTION COMMON USING TraceFlush 1
$ db2 UPDATE CLI CFG FOR SECTION COMMON USING TraceTimeStamp 3
$ db2 GET CLI CFG FOR SECTION COMMON

In this specific case I'd look for the APPLHEAPSZ value as I know the IBM_DB and CLI drivers are sometimes pushing the limits even beyond 1024. We usually set that to 1024 when running the Rails test suite, but for certain Rails applications this might require an even higher value.

Even though the APPLHEAPSZ might be set to automatic, I'd recommend using a value at least 1024.

$ db2 connect to railsdb
$ db2 get db cfg |grep APPLHEAPSZ
Default application heap (4KB) (APPLHEAPSZ) = AUTOMATIC

$ db2 update db cfg using APPLHEAPSZ 1024
$ db2stop
$ db2start

By: Nathan Witmer
uncaught throw 'Fetch error' [ reply ]  
2007-11-20 19:54
I'm getting inexplicable 500 server errors due to uncaught throws from the db2 driver. I can't reproduce them reliably, they just show up every twenty or thirty requests. Do you have any suggestions?

<code><pre>
ThreadError (uncaught throw `Fetch Failure: ' in thread 0x883efd8):
/vendor/plugins/ibm_db/lib/active_record/connection_adapters/ibm_db_adapter.rb:1192:in `fetch_assoc'
/vendor/plugins/ibm_db/lib/active_record/connection_adapters/ibm_db_adapter.rb:1192:in `select_all'
/vendor/plugins/ibm_db/lib/active_record/connection_adapters/ibm_db_adapter.rb:479:in `select_all'
/vendor/rails/activerecord/lib/active_record/base.rb:447:in `find_by_sql'
/vendor/rails/activerecord/lib/active_record/base.rb:1035:in `find_every'
/vendor/rails/activerecord/lib/active_record/base.rb:438:in `find'
/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb:66:in `find'
/app/models/ref/xref_catalog.rb:53:in `search'
/app/models/ods/asset_builder.rb:230:in `transform_organization'
/app/models/ods/asset_builder.rb:131:in `send'
/app/models/ods/asset_builder.rb:131:in `build_asset_from_params'
/app/models/ods/asset_builder.rb:130:in `each'
/app/models/ods/asset_builder.rb:130:in `build_asset_from_params'
/app/models/ods/asset_builder.rb:50:in `initialize'
/app/controllers/assets_controller.rb:18:in `new'
/app/controllers/assets_controller.rb:18:in `create'
/vendor/rails/actionpack/lib/action_controller/base.rb:1137:in `send'
/vendor/rails/actionpack/lib/action_controller/base.rb:1137:in `perform_action_without_filters'
/vendor/rails/actionpack/lib/action_controller/filters.rb:697:in `call_filters'
/vendor/rails/actionpack/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'
/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/vendor/rails/actionpack/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'
/vendor/rails/actionpack/lib/action_controller/caching.rb:669:in `perform_action'
/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
/vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
/vendor/rails/actionpack/lib/action_controller/caching.rb:668:in `perform_action'
/vendor/rails/actionpack/lib/action_controller/base.rb:513:in `send'
/vendor/rails/actionpack/lib/action_controller/base.rb:513:in `process_without_filters'
/vendor/rails/actionpack/lib/action_controller/filters.rb:685:in `process_without_session_management_support'
/vendor/rails/actionpack/lib/action_controller/session_management.rb:123:in `process'
/vendor/rails/actionpack/lib/action_controller/base.rb:377:in `process'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:171:in `handle_request'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:115:in `dispatch'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:9:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `run'
/usr/lib/ruby/gems/1.8/gems/swiftiply-0.6.1/bin/mongrel_rails:136:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run'
/usr/lib/ruby/gems/1.8/gems/swiftiply-0.6.1/bin/mongrel_rails:252
/usr/bin/mongrel_rails:16:in `load'
/usr/bin/mongrel_rails:16



</pre></code>