Rails Sessions and marshal data too short

July 12, 2008

I’ve been struggling a bit with a case of

marshal data too short

for one of my users. It happened out of the blue, and I was stumped as to how it could happen, as I only save a couple of ID’s in the sessions and never any objects.

Turns out I forgot something which is pretty obvious, really.

flash['notice'] = "#{link_to_task_with_tooltip} successfully saved"

As the tooltip contains the full task description, what would happen if someone entered a massive description (~65kb) and saved the task?

It would case the session data to get truncated on save, and end up impossible to restore on the next request.

Also, the exception when this happens doesn’t really include any useful information (like which session it was unable to restore) so I thought this was a way more common problem than it really was. Turns out this problem only affected two users, but they both kept trying and trying and it looked like I had this problem all over the place.

Fix coming up. 🙂


3 Responses to “Rails Sessions and marshal data too short”

  1. Lucy Says:

    I’ve been using Weft QDA to code qualitative data. Now I’m getting the message ‘marshal data too short’ every time I try to open my file. I think because my laptop had a power problem and cut out while using the programme.

    I was trying to look up a solution and came across this entry. Do you know of any fix I can do to make the file open normally again?

    Thanks in advance,
    Lucy (lucyehollis@gmail.com)

  2. As I have no idea what Weft QDA is, or what file you’re trying to open, I don’t think I can help you much.

    My problem was that the session data being truncated due to some too big data getting stored and ending up truncated when saved to the database.

    — Erlend

  3. joeellis Says:

    Just thought I’d leave a note and say that if you’re using MySQL, and need big sessions but keep hitting this problem, trychanging the data fields in your sessions field to “longtext” That will give your DB more than enough space to work with.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: