# Marshal data too short -- getting this all the time now

**URL:** <https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722>\
**Category:** Rails\
**Created:** [February 25, 2007, 2:26am UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722 "2007-02-25T02:26:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffpritchard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@jeffpritchard](https://www.ruby-forum.com/u/jeffpritchard)\
**Post date:** [February 25, 2007, 2:26am UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722/1 "2007-02-25T02:26:33Z")

</div>

I’m getting this never before seen error quite a bit all of a sudden:  
marshal data too short

It shows up as an application error just after a “stale\_session\_check”  
in the stack dump in the error log.

Anybody know what it means? Why it happens? The only solution I’ve  
found so far is to use mySQL admin to delete the session data. It has  
been happening often enough today that it is really slowing me down but  
I have no clue what’s broke.

thanks,  
jp

---

<div class="post-metadata">

**Author:** ![jeffpritchard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@jeffpritchard](https://www.ruby-forum.com/u/jeffpritchard)\
**Post date:** [February 25, 2007, 5:54pm UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722/2 "2007-02-25T17:54:31Z")

</div>

jens wille wrote:

> what helped in my case was to set the type of the ‘data’ column in  
> the ‘sessions’ table to ‘longtext’ (or ‘mediumtext’) instead of ‘text’.
> 
> note, however, that this is specific to mysql and if you’re using  
> migrations you need to set it manually: t.columns \<\< ‘data longtext’  
> (at the end of your ‘create\_table’ block).
> 
> hth  
> jens

Interesting. I’ll give it a try. Thanks!

jp

---

<div class="post-metadata">

**Author:** ![jeffpritchard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@jeffpritchard](https://www.ruby-forum.com/u/jeffpritchard)\
**Post date:** [February 25, 2007, 11:04am UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722/3 "2007-02-25T11:04:24Z")

</div>

hi jeff!

Jeff P. [25.02.2007 02:26]:

> I’m getting this never before seen error quite a bit all of a  
> sudden: marshal data too short  
> what helped in my case was to set the type of the ‘data’ column in  
> the ‘sessions’ table to ‘longtext’ (or ‘mediumtext’) instead of ‘text’.

note, however, that this is specific to mysql and if you’re using  
migrations you need to set it manually: t.columns \<\< ‘data longtext’  
(at the end of your ‘create\_table’ block).

hth  
jens

–  
Jens W., Dipl.-Bibl. (FH)  
prometheus - Das verteilte digitale Bildarchiv für Forschung & Lehre  
An St. Laurentius 4, 50931  
KölnTel.: +49 (0)221 470-6668, E-Mail: removed\_email\_address@domain.invalid  
[http://www.prometheus-bildarchiv.de/](http://www.prometheus-bildarchiv.de/)

---

<div class="post-metadata">

**Author:** ![jeffpritchard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@jeffpritchard](https://www.ruby-forum.com/u/jeffpritchard)\
**Post date:** [March 6, 2007, 9:16pm UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722/4 "2007-03-06T21:16:39Z")

</div>

Hi Mathieu,

‘marshal data too short’ is usually caused by the session data column in  
the sessions table being too short to handle large session data.  
Whatever the database you’re using, the default migration sets it to a  
preset size (TEXT in MySQL) and if your session is too large, it will  
cause the marshaled data checksum to fail. Try setting your column type  
to something larger (in MySQL, LONGTEXT works better).

Mathieu Jobin wrote:

> I’m having the same problem as jeff. ‘marshal data too short’ but I am  
> not using mysql for session storage. I left it to the default and the  
> sessions are stored on disk. I have 27000 registered users on my system  
> and this problem happens for only two of these users. I have no idea  
> what that could be from…
> 
> jens wille wrote:
> 
> > hi jeff!
> > 
> > Jeff P. [25.02.2007 02:26]:
> > 
> > > I’m getting this never before seen error quite a bit all of a  
> > > sudden: marshal data too short  
> > > what helped in my case was to set the type of the ‘data’ column in  
> > > the ‘sessions’ table to ‘longtext’ (or ‘mediumtext’) instead of ‘text’.
> > 
> > note, however, that this is specific to mysql and if you’re using  
> > migrations you need to set it manually: t.columns \<\< ‘data longtext’  
> > (at the end of your ‘create\_table’ block).
> > 
> > hth  
> > jens
> > 
> > –  
> > Jens W., Dipl.-Bibl. (FH)  
> > prometheus - Das verteilte digitale Bildarchiv fï¿½r Forschung & Lehre  
> > An St. Laurentius 4, 50931  
> > Kï¿½lnTel.: +49 (0)221 470-6668, E-Mail: removed\_email\_address@domain.invalid  
> > [http://www.prometheus-bildarchiv.de/](http://www.prometheus-bildarchiv.de/)

---

<div class="post-metadata">

**Author:** ![jeffpritchard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@jeffpritchard](https://www.ruby-forum.com/u/jeffpritchard)\
**Post date:** [March 6, 2007, 4:13am UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722/5 "2007-03-06T04:13:31Z")

</div>

I’m having the same problem as jeff. ‘marshal data too short’ but I am  
not using mysql for session storage. I left it to the default and the  
sessions are stored on disk. I have 27000 registered users on my system  
and this problem happens for only two of these users. I have no idea  
what that could be from…

jens wille wrote:

> hi jeff!
> 
> Jeff P. [25.02.2007 02:26]:
> 
> > I’m getting this never before seen error quite a bit all of a  
> > sudden: marshal data too short  
> > what helped in my case was to set the type of the ‘data’ column in  
> > the ‘sessions’ table to ‘longtext’ (or ‘mediumtext’) instead of ‘text’.
> 
> note, however, that this is specific to mysql and if you’re using  
> migrations you need to set it manually: t.columns \<\< ‘data longtext’  
> (at the end of your ‘create\_table’ block).
> 
> hth  
> jens
> 
> –  
> Jens W., Dipl.-Bibl. (FH)  
> prometheus - Das verteilte digitale Bildarchiv fï¿½r Forschung & Lehre  
> An St. Laurentius 4, 50931  
> Kï¿½lnTel.: +49 (0)221 470-6668, E-Mail: removed\_email\_address@domain.invalid  
> [http://www.prometheus-bildarchiv.de/](http://www.prometheus-bildarchiv.de/)

---

<div class="post-metadata">

**Author:** ![jeffpritchard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@jeffpritchard](https://www.ruby-forum.com/u/jeffpritchard)\
**Post date:** [May 5, 2007, 4:01pm UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722/6 "2007-05-05T16:01:23Z")

</div>

I believe this has something to do with a corrupt session file. If you  
empty out your tmp/session dir or remove the session files of those  
people it will probably work again.

Let me know what happened.  
Marco

Mathieu Jobin wrote:

> Hi Milan, thanks for your answer.  
> but I dont use a DB for session storage, but the default on disk in  
> RAILS\_ROOT/tmp/sessions
> 
> I only store IDs and short strings in the session, no big object.  
> i really don’t understand why I am getting this error.
> 
> and I am getting this error only when 3 of my 27000 users login.  
> it works fine for most people.
> 
> I’m out of ideas…
> 
> Milan Iliev wrote:
> 
> > Hi Mathieu,

---

<div class="post-metadata">

**Author:** ![jeffpritchard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@jeffpritchard](https://www.ruby-forum.com/u/jeffpritchard)\
**Post date:** [June 13, 2007, 10:13pm UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722/7 "2007-06-13T22:13:54Z")

</div>

Hey guys, Im experiencing the exact same thing. Normally the data column  
would never even be even close to reaching its character limit. The  
problem is that, all of a sudden, when data gets written to the session  
data column, its writes the data for a few lines and then starts  
repeating

“YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh”

until its out of space. Im sure thats causing the error. Anybody seen  
this before?

Marco Kotrotsos wrote:

> I believe this has something to do with a corrupt session file. If you  
> empty out your tmp/session dir or remove the session files of those  
> people it will probably work again.
> 
> Let me know what happened.  
> Marco
> 
> Mathieu Jobin wrote:
> 
> > Hi Milan, thanks for your answer.  
> > but I dont use a DB for session storage, but the default on disk in  
> > RAILS\_ROOT/tmp/sessions
> > 
> > I only store IDs and short strings in the session, no big object.  
> > i really don’t understand why I am getting this error.
> > 
> > and I am getting this error only when 3 of my 27000 users login.  
> > it works fine for most people.
> > 
> > I’m out of ideas…
> > 
> > Milan Iliev wrote:
> > 
> > > Hi Mathieu,

---

<div class="post-metadata">

**Author:** ![jeffpritchard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@jeffpritchard](https://www.ruby-forum.com/u/jeffpritchard)\
**Post date:** [April 5, 2007, 2:48am UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722/8 "2007-04-05T02:48:51Z")

</div>

Hi Milan, thanks for your answer.  
but I dont use a DB for session storage, but the default on disk in  
RAILS\_ROOT/tmp/sessions

I only store IDs and short strings in the session, no big object.  
i really don’t understand why I am getting this error.

and I am getting this error only when 3 of my 27000 users login.  
it works fine for most people.

I’m out of ideas…

Milan Iliev wrote:

> Hi Mathieu,
> 
> ‘marshal data too short’ is usually caused by the session data column in  
> the sessions table being too short to handle large session data.  
> Whatever the database you’re using, the default migration sets it to a  
> preset size (TEXT in MySQL) and if your session is too large, it will  
> cause the marshaled data checksum to fail. Try setting your column type  
> to something larger (in MySQL, LONGTEXT works better).
> 
> Mathieu Jobin wrote:
> 
> > I’m having the same problem as jeff. ‘marshal data too short’ but I am  
> > not using mysql for session storage. I left it to the default and the  
> > sessions are stored on disk. I have 27000 registered users on my system  
> > and this problem happens for only two of these users. I have no idea  
> > what that could be from…
> > 
> > jens wille wrote:
> > 
> > > hi jeff!
> > > 
> > > Jeff P. [25.02.2007 02:26]:
> > > 
> > > > I’m getting this never before seen error quite a bit all of a  
> > > > sudden: marshal data too short  
> > > > what helped in my case was to set the type of the ‘data’ column in  
> > > > the ‘sessions’ table to ‘longtext’ (or ‘mediumtext’) instead of ‘text’.
> > > 
> > > note, however, that this is specific to mysql and if you’re using  
> > > migrations you need to set it manually: t.columns \<\< ‘data longtext’  
> > > (at the end of your ‘create\_table’ block).
> > > 
> > > hth  
> > > jens
> > > 
> > > –  
> > > Jens W., Dipl.-Bibl. (FH)  
> > > prometheus - Das verteilte digitale Bildarchiv fï¿½r Forschung & Lehre  
> > > An St. Laurentius 4, 50931  
> > > Kï¿½lnTel.: +49 (0)221 470-6668, E-Mail: removed\_email\_address@domain.invalid  
> > > [http://www.prometheus-bildarchiv.de/](http://www.prometheus-bildarchiv.de/)

---

<div class="post-metadata">

**Author:** ![jeffpritchard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@jeffpritchard](https://www.ruby-forum.com/u/jeffpritchard)\
**Post date:** [December 15, 2008, 10:44am UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722/9 "2008-12-15T10:44:35Z")

</div>

Hi, I ended up with this problem, but having a six hundred thousands  
records in my sessions tableâ€¦  
Surely’ve been hacked;  
The site are protected with a simple login page (salt & hash, successful  
create a user session) and is just on the web for development/production  
testing.  
I wonder exactly how it has happenned; The logs don’t show any  
activities !!!  
might be something like XSS, but if it seems obvious for some of you,  
thanks for the info you’d provide.

> For MySQL db, here is the migration to change to longtext:
> 
> ```auto
> class ChangeSessions2 < ActiveRecord::Migration
> > def self.up
> > execute "ALTER TABLE sessions CHANGE COLUMN data data LONGTEXT"
> > end
> > 
> > def self.down
> > end
> > end
> > 
> ```
> 
> Regards,
> 
> LarryK

---

<div class="post-metadata">

**Author:** ![jeffpritchard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@jeffpritchard](https://www.ruby-forum.com/u/jeffpritchard)\
**Post date:** [December 5, 2007, 4:51pm UTC](https://www.ruby-forum.com/t/marshal-data-too-short-getting-this-all-the-time-now/86722/10 "2007-12-05T16:51:07Z")

</div>

For MySQL db, here is the migration to change to longtext:

```auto
class ChangeSessions2 < ActiveRecord::Migration
  def self.up
    execute "ALTER TABLE sessions CHANGE COLUMN data data LONGTEXT"
  end

  def self.down
  end
end

```

Regards,

LarryK
