NetManiac

Witold Rugowski on web20 wave with Ruby on Rails

ArgumentError: marshal data too short when loading session data

Posted on August 20, 2010 - Filed Under RubyOnRails

If you're new here, you may want to subscribe to my RSS feed. You can also get updates by email Thanks for visiting!

I was stuck for a while when application maintained by me have started to throw ArgumentError: marshal data too short errors in random places When user have encountered that problem then it was unable to use application at all.

Marshal

Marshal CC http://www.flickr.com/photos/qmnonic/

Logs were showing that it happens when Rails was trying to create session object. Session store was in ActiveRecord and sessions table was not corrupted.

After watching that for a while it have shown that places in code were this exception was thrown were random but there was pattern. Page visited before was common in each case.

It have turned out that application was storing in session whole ActiveRecord object. Like:

 session[:some_info] = @variable

And later we were trying to use that way:

@variable = Model.find session[:some_info]

Due to Rails magic AcitiveRecord’s find when provided with AR object will return that object (of course if is the same model). Code was working well (maybe not very effectively since You should avoid storing large objects in session) until object stored that way started to grow. Application was collecting some data and amount of data stored have grown to that point that after Marshal.dump size of string was more than 64 kB. And this is default size of text field used to store session data in MySQL.

When You try to store too much data in text field in MySQL, excessive data is being truncated, so Marshal.load throws that exception.

To have that error solved is enough to store just object id in session (session[:some_info] = @variable.id).

Popularity: 2% [?]

CHM should be in…

Posted on July 22, 2010 - Filed Under Uncategorized

Well… Long time… But finally a new post!

If You have drank Linux KoolAid, then You can run on problems when You get some CHM file. It is old format and I think it has place where it can live (like many other proprietary data formats):

Place where we should send .chm files

Place where we should send .chm files (c) Marcin Wichary

But still, You can get documentation in such format, chances are high if You are trying to interface some .Net SOAP service. In Linux - no viewer for CHM.

Or rather no standalone viewer. There is solution - CHM Reader addon for Firefox. It is not perfect (no global search), but allows to navigate through that file. Printouts to PDF usually are stripped from hyperlinks, so navigating through 800 pages is reason why PDF printout is not an option…

Popularity: 2% [?]

Thumbnails are missing when uploading new image

Posted on March 7, 2010 - Filed Under wordpress

Just a quick note - if You are experiencing missing thumbnails in image upload in Wordpress, then probably Your PHP installation misses php-gd module.

It is module by default installed on FreeBSD, but on Debian based Linux You have to add it by hand (apt-get install php5-gd).

I had to move my blogs to new, temporary host, with Linux on board instead of FreeBSD. Then I have noticed that when I want to publish new post I can only insert in it uploaded image in original size - not very handy. It took 15 minutes of googling and finally dive into wp-includes/media.php to check how these thumbnails are generated.

Popularity: 7% [?]

Ruby for Startups

Posted on January 19, 2010 - Filed Under RubyOnRails

I’ve found this interesting - a bunch of info from Mike Subelsky (creator of OtherInbox) how to use Ruby and Rails in challenging startup environment (each startup’s environment is challenging :)) )

Popularity: 14% [?]

Email verification - regexp

Posted on January 13, 2010 - Filed Under Ruby, Uncategorized, web

Many times before when I was supposed to collect emails from users I was googling to find some regexp to verify email syntax. At least I was aware that regexp challenging email address syntax is a bullshit ;) I was working few years as Unix sysadmin mostly on mail servers, so I had some idea how RFCs related to email are bloated ;) and contain so many exceptions ;)

Step back and think again

Step back and think again. Image CC by Vivianna_love

From some time I do use following regexp to verify email address:

 /.+@.+[.].+/

This should check if:

Why such simple rules? I have found comment on StackOverflow, that man should step back and think why is checking email address?

I want just to help users and stop them making simple mistakes in theirs emails. Like not providing @ at all. Or eating .com in gmail.com address. And that’s it - email will be probably shortly after that verified with only reliable method via sending email to this address.

And if You insist to verify emails with more strict regular expression, please do remember that plus sign is perfectly valid character before @. Many regexps found via google are forgetting that…

Popularity: 14% [?]

older entries »