# Strange problem in production

**URL:** <https://www.ruby-forum.com/t/strange-problem-in-production/114066>\
**Category:** Rails\
**Created:** [September 7, 2007, 3:04pm UTC](https://www.ruby-forum.com/t/strange-problem-in-production/114066 "2007-09-07T15:04:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ADADAD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ADADAD](https://www.ruby-forum.com/u/ADADAD)\
**Post date:** [September 7, 2007, 3:04pm UTC](https://www.ruby-forum.com/t/strange-problem-in-production/114066/1 "2007-09-07T15:04:44Z")

</div>

let’s say I have some authors and update their books list (very  
complicated algorithm).

Everything works great in development mode, however in production mode  
the id’s get mixed, the books get assigned to the wrong author (maybe  
if 2 or more requests happen in the same time), like somehow they  
share some variables. This is not happen in development mode (same  
conditions).

Any idea why this can happen?

Thanks,  
Al

---

<div class="post-metadata">

**Author:** ![ADADAD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ADADAD](https://www.ruby-forum.com/u/ADADAD)\
**Post date:** [September 7, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/strange-problem-in-production/114066/2 "2007-09-07T16:33:01Z")

</div>

Hey AD,  
I am not sure here, but i suspect might this is the problem,  
concurrency.  
just check with some sample application with small data set.

P.s:  
As i said i am not sure.

---

<div class="post-metadata">

**Author:** ![ADADAD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ADADAD](https://www.ruby-forum.com/u/ADADAD)\
**Post date:** [September 7, 2007, 4:45pm UTC](https://www.ruby-forum.com/t/strange-problem-in-production/114066/3 "2007-09-07T16:45:03Z")

</div>

of course it is concurrency, but why? I can’t avoid this, the request  
came from the web, so obviously I somehow use some kind of static  
variable shared between processed, only I don’t even know if static  
variables exists…

The main hint can be that is happen only in production mode, so I’m  
still looking for an idea.

Thanks,  
Al

---

<div class="post-metadata">

**Author:** ![ADADAD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ADADAD](https://www.ruby-forum.com/u/ADADAD)\
**Post date:** [September 8, 2007, 4:34am UTC](https://www.ruby-forum.com/t/strange-problem-in-production/114066/4 "2007-09-08T04:34:18Z")

</div>

I don’t have ☹

But I found the answer (not yet the error) in an old post of javier  
ramirez:

of yep… when you are in development mode, the classes (most of them  
anyhow) get reloaded at each request. This means the code is  
reinterpreted every time and that’s why: a) you don’t need to restart  
so  
it’s cool to try things quickly, and: b) it’s much slower than running  
in production mode.

When in production, the classes get interpreted when loaded, and they  
are not reinterpreted every time. That’s why you need to restart the  
server when you change the code. This means the class variables will  
keep their values between calls unless you modify them explicitely.

Now I need to find the error.

Thanks

---

<div class="post-metadata">

**Author:** ![ADADAD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ADADAD](https://www.ruby-forum.com/u/ADADAD)\
**Post date:** [September 8, 2007, 11:29am UTC](https://www.ruby-forum.com/t/strange-problem-in-production/114066/5 "2007-09-08T11:29:40Z")

</div>

Hi,

> Now I need to find the error.

it looks like the error could be in the use of class/global variables.  
Look for cattr and for $ in your classes (and i hope you are not doing  
that, but look also for $ in your views). Class attributes and global  
variables are shared for the whole process (meaning your  
mongrel/webrick).

good luck,

javier ramirez

---

<div class="post-metadata">

**Author:** ![ADADAD](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ADADAD](https://www.ruby-forum.com/u/ADADAD)\
**Post date:** [September 7, 2007, 5:07pm UTC](https://www.ruby-forum.com/t/strange-problem-in-production/114066/6 "2007-09-07T17:07:07Z")

</div>

Have you written your tests and do they pass?

Rein
