Alex Rivera | Logout

marshal data too short

Asked 2009-12-18T13:29:13.417
13

My application requires to keep large data objects in session. There are like 3-4 data objects each created by parsing a csv containing 150 X 20 cells having strings of 3-4 characters. My application shows this error- "marshal data too short". I tried this-

  • Deleting the old session table.
  • Deleting the old migration for session table.
  • Creating a new migration using rake db:sessions:create.
  • editing the migration manually, changing text: data to longtext: data.
  • running the migration using rake db:migrate.

other details of application--

In view "index.html.erb"- There is a link that makes ajax call to an action in controller, that action parses large csv file and makes an object out of it. this object is stored in session.

ERROR LOG

` ArgumentError in Scoring#index

Showing app/views/scoring/index.html.erb where line #4 raised:

marshal data too short

Extracted source (around line #4):

1: 
2: <form id="myForm">
3: 
4:   <%= link_to_remote "get csv file",
5:        :url      => { :action => 'show_static_1' },
6:        :update   => "static_score",
7:        :complete => "$('static_score').update(request.responseText)" %>

Application Trace | Framework Trace | Full Trace

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `load'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `unmarshal'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:110:in `data'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:292:in `get_session'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1448:in `silence'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:288:in `get_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3
Edit
Report

2 Answers

6

What shows up in the error log after you access the page that gives that error?

Also, what is the column type for your session information in MySQL? TEXT?

------------- EDIT BELOW ----------------

Ok, as far as I've been able to determine, this error generally means that the size of the content that you are shoving in the session is too large for the MySQL column. The most common solution cited seems to point towards a solution of changing the column from TEXT to LONGTEXT.

Try running something like this in MySQL and see if it gives you any improvement:

ALTER TABLE sessions CHANGE COLUMN data data LONGTEXT

The obvious solution is to not store the CSV data in the session as that's probably not the best place to put it, but I don't know your reasons behind what you're doing, so maybe you have no other options.

Give that a try and let me know if it worked.

answered 2009-12-18T15:02:35.960
3

The previous solutions didn't work for me. What did work for me was to clear the session's cache with

rake db:sessions:clear
answered 2011-08-18T14:56:41.133

Your Answer