Hi all,
I am experiencing an error when reading session data. The problem is
that it doesn’t happen all the time, in most cases it doesn’t occur.
But it does so enough to start to become annoying.
It happens when trying to read a session record’s data property. The
session store is in the Postgres database (version 8.2) and the
sessions.data column is of type text (so theoretically unlimited in
size).
Now I believe the error can happen in relation to data being truncated
and then when it’s marshalled back it’s then found to be too short.
But with the sessions.data column being of type text and the session
information that is being stored not being of any great size (not even
close), I’m not sure what the problem could be.
This is the snippet of code where the error occurs:
session_store = CGI::Session::ActiveRecordStore::Session
sessions = session_store.find(:all, :conditions => [“updated_at > ?”,
1.hour.ago], :order => “updated_at”)
user_session_data = {}
sessions.each do |sess|
next unless sess.data && sess.data.has_key?(:user_id)
user_session_data[sess.data[:user_id]] = sess.updated_at
end
The exception happens on this call: next unless sess.data. In the call
to sess.data.
I’ve included the trace below for reference.
Has anyone else experience this problem? Any help would be greatly
appreciated.
Cheers,
Diego
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/session/
active_record_store.rb:84:in load' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/session/ active_record_store.rb:84:in
unmarshal’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/session/
active_record_store.rb:122:in data' [RAILS_ROOT]/app/models/user.rb:113:in
logged_in_users’
[RAILS_ROOT]/app/models/user.rb:112:in each' [RAILS_ROOT]/app/models/user.rb:112:in
logged_in_users’
[RAILS_ROOT]/app/controllers/users_controller.rb:48:in
logged_in_users' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb: 1095:in
send’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:
1095:in perform_action_without_filters' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 632:in
call_filter’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
638:in call_filter' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 438:in
call’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
637:in call_filter' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 638:in
call_filter’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
438:in call' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 637:in
call_filter’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
638:in call_filter' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 438:in
call’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
637:in call_filter' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 638:in
call_filter’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
438:in call' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 637:in
call_filter’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
638:in call_filter' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 438:in
call’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
637:in call_filter' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 634:in
call_filter’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
638:in call_filter' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 438:in
call’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
637:in call_filter' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 638:in
call_filter’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
449:in call' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 637:in
call_filter’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
638:in call_filter' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 449:in
call’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
637:in call_filter' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb: 619:in
perform_action_without_benchmark’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/
benchmarking.rb:66:in perform_action_without_rescue' /usr/local/lib/ruby/1.8/benchmark.rb:293:in
measure’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/
benchmarking.rb:66:in perform_action_without_rescue' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/rescue.rb: 83:in
perform_action’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:
430:in send' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb: 430:in
process_without_filters’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/filters.rb:
624:in process_without_session_management_support' [RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/ session_management.rb:114:in
process’
[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/base.rb:
330:in process' [RAILS_ROOT]/vendor/rails/railties/lib/dispatcher.rb:41:in
dispatch’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/
rails.rb:84:in process' /usr/local/lib/ruby/1.8/sync.rb:229:in
synchronize’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/
rails.rb:83:in process' /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb: 580:in
process_client’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:
579:in each' /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb: 579:in
process_client’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:
686:in run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb: 686:in
initialize’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:
686:in new' /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb: 686:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:
673:in initialize' /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb: 673:in
new’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:
673:in run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/ configurator.rb:267:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/
configurator.rb:266:in each' /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/ configurator.rb:266:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/bin/mongrel_rails:
127:in run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/ command.rb:211:in
run’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/bin/mongrel_rails:
231
/usr/local/bin/mongrel_rails:16:in `load’
/usr/local/bin/mongrel_rails:16