# How to debug session error

**URL:** <https://www.ruby-forum.com/t/how-to-debug-session-error/129841>\
**Category:** Rails\
**Created:** [February 22, 2008, 12:32am UTC](https://www.ruby-forum.com/t/how-to-debug-session-error/129841 "2008-02-22T00:32:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [February 22, 2008, 12:32am UTC](https://www.ruby-forum.com/t/how-to-debug-session-error/129841/1 "2008-02-22T00:32:51Z")

</div>

My rails (1.1.6) wep application has been working fine for months, with  
15 000 user per day. never had any problem with session.

Then I added a new feature to my app, and, after 4 to 6 hours, sessions  
start to be lost.  
I mean, i set a session[“a”] = stuff, at the next call, session[“a”]  
will be nil !!!  
So my user can not login…because of the session[“user\_id”]

If i restart my application, it works fine for an extra 4 to 6 hour.

If i rollback my application to before the new feature, it works fine.

here is my new feature:

begin  
timeout(15) do  
puts system( EXECUTE AN OPENOFFICE MACRO )  
end  
rescue Timeout::Error =\> err  
log  
rescue Exception =\> err  
log  
end

So the new feature is to upload user file, and handle then with an  
openoffice macro with a system command…

Sometime, the command fail…

Could it be possible that this command have some impact on the rails  
session managment system ?

My session are stored in a Mysql DB.

Please help, any clue are welcome

---

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [February 22, 2008, 12:33am UTC](https://www.ruby-forum.com/t/how-to-debug-session-error/129841/2 "2008-02-22T00:33:29Z")

</div>

or, is there any way to debug session management in rails ?

---

<div class="post-metadata">

**Author:** ![oldbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c0e974/32.png) [@oldbug](https://www.ruby-forum.com/u/oldbug)\
**Post date:** [February 22, 2008, 11:23am UTC](https://www.ruby-forum.com/t/how-to-debug-session-error/129841/3 "2008-02-22T11:23:44Z")

</div>

On 21 Feb 2008, at 23:32, Hakita Hakita wrote:

> will be nil !!!  
> puts system( EXECUTE AN OPENOFFICE MACRO )  
> end  
> rescue Timeout::Error =\> err  
> log  
> rescue Exception =\> err  
> log  
> end

You may be running into the problem I wrote about here:

> **[钛刻专家——官网](https://www.texperts.com/2007/05/01/race-conditions-in-rails-sessions-and-how-to-fix-them/)**
>
> 钛刻专家致力于打造一个全球专家在线服务平台，为机构和个人对接高水平行业专家，为机构提供更系统性的线下定制专家服务。

Short version: because you’ve got such a long running action, it is  
very likely that you’ll get concurrent requests from the same user and  
the different updates to the session overwrite each other.

Fred
