sporadic data retrieval failure

Hi,

I've been banging my head against this problem for a while, trying to figure out where it's occurring. I have a (I believe) relatively simple application, not entirely unlike a typical shopping cart, which is generating errors upon *some* page loads.

The errors are along the lines of "ActiveRecord::RecordNotFound (Couldn't find Estimate with ID=3)". The odd part about this is that refreshing the page (which attempts to again locate the estimate with id=3) succeeds - at least in all experiences, although I imagine it could fail twice in a row. So, the data is there an exists, but there's a failure somewhere in the retrieval process.

I have two machines I am testing this on, one is a macbook pro, running Leopard, the other a p4 running FreeBSD 6.2. Below is software information for each machine:

Mac:
ruby 1.8.6 (2007-06-07 patchlevel 36) [universal-darwin9.0]
Rails 1.2.5
Mongrel Web Server 1.1.1
postgres (0.7.1) - ruby gem for accessing postgresql (have also tried postgres-pr, with same result)
psql (PostgreSQL) 8.2.5

FreeBSD box:
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-freebsd6]
Rails 1.2.5
Mongrel Web Server 1.1.1
postgres-pr (0.4.0)
psql (PostgreSQL) 8.2.5

Both setups experience the same issue.

Below are two renderings of the same page, the second of which generated an error about not finding the exact same estimate I had just seen a moment before (and could view again upon reloading the page).

Processing EstimatesController#overview (for 10.135.3.4 at 2007-11-13 16:05:03) [GET]
   Session ID: b5b727036080e1dacdfdbafa2ec5214d
   Parameters: {"action"=>"overview", "id"=>"3", "controller"=>"estimates"}
   SQL (0.003406) 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

   User Load (0.002104) SELECT * FROM users WHERE (users."id" = 2) LIMIT 1
   SQL (0.015020) 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 = 'estimates'::regclass
  AND a.attnum > 0 AND NOT a.attisdropped
  ORDER BY a.attnum

   Estimate Load (0.011749) SELECT * FROM estimates WHERE (estimates."id" = 3)
Rendering within layouts/application
Rendering estimates/overview
   DocumentItem Load (0.003368) SELECT * FROM document_items WHERE (document_items.estimate_id = 3)
   SQL (0.003763) 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 = 'document_items'::regclass
  AND a.attnum > 0 AND NOT a.attisdropped
  ORDER BY a.attnum

   Subcontract Load (0.001655) SELECT * FROM subcontracts WHERE (subcontracts.estimate_id = 3)
Rendered estimates/_glimpse (0.06406)
Rendered estimates/_submenu (0.06745)
Completed in 0.34335 (2 reqs/sec) | Rendering: 0.28281 (82%) | DB: 0.04106 (11%) | 200 OK [http://mon/estimates/overview/3]

Processing EstimatesController#overview (for 10.135.3.4 at 2007-11-13 16:05:04) [GET]
   Session ID: b5b727036080e1dacdfdbafa2ec5214d
   Parameters: {"action"=>"overview", "id"=>"3", "controller"=>"estimates"}
   SQL (0.003458) 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

   User Load (0.002108) SELECT * FROM users WHERE (users."id" = 2) LIMIT 1
   SQL (0.015140) 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 = 'estimates'::regclass
  AND a.attnum > 0 AND NOT a.attisdropped
  ORDER BY a.attnum

   Estimate Load (0.087658) SELECT * FROM estimates WHERE (estimates."id" = 3)

ActiveRecord::RecordNotFound (Couldn't find Estimate with ID=3):
     /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/base.rb:1031:in `find_one'
     /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/base.rb:1014:in `find_from_ids'
     /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/base.rb:419:in `find_without_pagination'
     /usr/home/joe/repo/rails/estimator/vendor/plugins/paginating_find/lib/paginating_find.rb:102:in `find'
     /usr/home/joe/repo/rails/estimator/app/controllers/estimates_controller.rb:219:in `overview'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:1101:in `send'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:1101:in `perform_action_without_filters'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/filters.rb:696:in `call_filters'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/filters.rb:688:in `perform_action_without_benchmark'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
     /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/rescue.rb:83:in `perform_action'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:435:in `send'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:435:in `process_without_filters'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/filters.rb:684:in `process_without_session_management_support'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/session_management.rb:114:in `process'
     /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:334:in `process'
     /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/dispatcher.rb:41:in `dispatch'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel/rails.rb:76:in `process'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel/rails.rb:74:in `synchronize'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel/rails.rb:74:in `process'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:155:in `process_client'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:154:in `each'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:154:in `process_client'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in `run'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in `initialize'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in `new'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:281:in `run'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in `initialize'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in `new'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel.rb:264:in `run'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/configurator.rb:282:in `run'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/configurator.rb:281:in `each'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/configurator.rb:281:in `run'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel_rails:128:in `run'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/lib/mongrel/command.rb:212:in `run'
     /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel_rails:281
     /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:488:in `load'
     /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:488:in `load'
     /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:342:in `new_constants_in'
     /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:488:in `load'
     /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/commands/servers/mongrel.rb:60
     /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
     /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
     /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in `require'
     /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:342:in `new_constants_in'
     /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in `require'
     /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/commands/server.rb:39
     /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
     /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
     script/server:3

Rendering /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/templates/rescues/layout.rhtml (500 Internal Error)

I'd love it if someone could help me track down this problem.

Thanks,
-Joe