Monday, May 21, 2007

Corrupt Session?

The system that I have been working on for the past while had a particularly vexing problem. Every morning, I had to restart the mongrel cluster. The reason, each morning the login process just stopped working. It was especially annoying, because I had one shot each day to attempt to fix it (to apply the fix, I had to restart the server). After a two weeks of various attempts at correcting the problem, we finally stumbled upon the problem.

class ApplicationController < ActionController::Base
session :session_expires => 12.hours.from_now

I was assuming that a session would gracefully expire 12 hours after first being created. In fact, what was happening is the session would expire 12 hours after the server restarted. So once twelve hours would pass, each request would generate a new session that would in essence be immediately expired. Not exactly the behavior I was looking for.

So if you are looking for corrupt session, session corruption, or unresponsive mongrel it may just be related to the code above.

Wednesday, May 09, 2007

A "Best Migration Practice"

So today, I discovered a "good idea" for migrations.

Put your database schema changes in one migration, then your data changes in the next. This becomes self-evident when you mix the two and watch as part way through your migration, the data change fails and suddenly your tables have been altered.