# Randomly dropping sessions

**URL:** <https://www.ruby-forum.com/t/randomly-dropping-sessions/157055>\
**Category:** Rails\
**Created:** [January 6, 2009, 11:37pm UTC](https://www.ruby-forum.com/t/randomly-dropping-sessions/157055 "2009-01-06T23:37:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce73a5/32.png) [@tim](https://www.ruby-forum.com/u/tim)\
**Post date:** [January 6, 2009, 11:37pm UTC](https://www.ruby-forum.com/t/randomly-dropping-sessions/157055/1 "2009-01-06T23:37:22Z")

</div>

Hey all,

Most of our customers get through our shopping cart no problem so  
orders continue to flow. However we’ve recently (past 10 days)  
started receiving reports of people not being able to add items to  
their cart. This seems to be affecting 2-3% of our customers. Taking  
a look at the logs I can see the sessions getting completely lost just  
as if the client had cookies disabled. I see no other warnings or  
errors.

We did have nearly 350k sessions accumulated in our sessions table  
which I cleared out to around 40k last night. We haven’t got any  
reports since then but I can’t say yet if it’s helped. I’m sure their  
have been other times when our sessions table got that large without  
this problem. We have \>\>very\<\< beefy hardware for our needs so I  
would expect to be able to handle that number of sessions without  
trouble.

The site has been up for going on 3 years with no significant issues  
and has had no code changes other than some minor template/html tweaks  
in a couple months.

ubuntu 8.10  
rails 2.1.0 && active\_record\_store  
mysql 5.0.51

Any thoughts greatly appreciated. Thanks in advance!  
Tim

---

<div class="post-metadata">

**Author:** ![tim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce73a5/32.png) [@tim](https://www.ruby-forum.com/u/tim)\
**Post date:** [January 8, 2009, 10:50am UTC](https://www.ruby-forum.com/t/randomly-dropping-sessions/157055/2 "2009-01-08T10:50:40Z")

</div>

Personally, I would add in the logic to clean up old sessions  
periodically or during login. Also, is there a reason you are not  
using Rails 2.1.2 or even better 2.2.2? Staying updated with Rails  
versions usually resolves any odd defect that you see.

Thanks,  
Mukund

---

<div class="post-metadata">

**Author:** ![tim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ce73a5/32.png) [@tim](https://www.ruby-forum.com/u/tim)\
**Post date:** [January 8, 2009, 7:02pm UTC](https://www.ruby-forum.com/t/randomly-dropping-sessions/157055/3 "2009-01-08T19:02:03Z")

</div>

Thanks for the input Muknd.

On Jan 8, 1:50 am, Mukund [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Personally, I would add in the logic to clean up old sessions  
> periodically or during login.

Yeah, when I said that I cleared them out I actually setup a cron job  
to do it regularly.

> Also, is there a reason you are not  
> using Rails 2.1.2 or even better 2.2.2? Staying updated with Rails  
> versions usually resolves any odd defect that you see.

I may soon but I suspect that’s not really the issue here. I  
typically don’t like to  
upgrade just for the sake of upgrading.

Thanks again!  
Tim
