# MySQL losts connection, can't refer to User

**URL:** <https://www.ruby-forum.com/t/mysql-losts-connection-cant-refer-to-user/89912>\
**Category:** Rails\
**Created:** [March 29, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/mysql-losts-connection-cant-refer-to-user/89912 "2006-03-29T14:17:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lopmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/258eb7/32.png) [@lopmx](https://www.ruby-forum.com/u/lopmx)\
**Post date:** [March 29, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/mysql-losts-connection-cant-refer-to-user/89912/1 "2006-03-29T14:17:58Z")

</div>

Hi

```
Another problem here. After the upgrade to 1.1 both rails and engines,

```

my app on windows crashes very often on requests. It can’t refer to User  
model or losts connection to mysql. It appears like 2-3 times per 10  
requests.

Eg.

Mysql::Error: Lost connection to MySQL server during query: UPDATE  
sessions SET `data` =  
'BAh7CiINcHJldl91cmkiHS9jYXNlcy9nZXRfY2FzZXM/d2hpY2g9MzoNbGFu\nZ3VhZ2UiCnBsLVBMIg5yZXR1cm4tdG8wOgl1c2VybzoJVXNlcgo6HEBuZXdf\ncmVjb3JkX2JlZm9yZV9zYXZlMDoQQGF0dHJpYnV0ZXN7GiIJc2FsdCItZmVm\nNmNlNTQ5NDg3OGI4NDRjYTQxYzRiNGNkODFmMGI4NzFkMjkwZiIRZGVsZXRl\nX2FmdGVyMCIPdXBkYXRlZF9hdHU6CVRpbWUNq4sagBi6CiUiD2FjY291bnRf\naWQwIhNzZWN1cml0eV90b2tlbiItOWMyNjEwODhhMGQ0Y2U4MTcyMjI1MDNi\nZjQ5OWMzMTA2Yzc4N2E3ZSIJcm9sZTAiDWxhc3RuYW1lIg5HcmFib3dza2ki\nDmZpcnN0bmFtZSILUmFmYcWCIgdpZCIGMSIQZGVzY3JpcHRpb24iACIKcGhv\nbmUiDjYwMzExMDY1NCIMZGVsZXRlZCIGMCIRdG9rZW5fZXhwaXJ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c2VyX2lkIgYxIhBzeXN0\nZW1fcm9sZSIGMW87HQY7CXsMQD4iCVVzZXJAQCIGMEBCIgYzQEQiBjNARiIt\nVGhlIGRlZmF1bHQgcm9sZSBmb3IgYWxsIGxvZ2dlZC1pbiB1c2Vyc0BIIgYx\nQEoiBjE6C0Bvd25lckAKOg5Aam9pbl9zcWwiPUlOTkVSIEpPSU4gdXNlcnNf\ncm9sZXMgT04gcm9sZXMuaWQgPSB1c2Vyc19yb2xlcy5yb2xlX2lkOgxAbG9h\nZGVkVDoQQGZpbmRlcl9zcWwiHXVz

ZXJzX3JvbGVzLnVzZXJfaWQgPSAxIDoM\nQGVycm9yc286GUFjdGl2ZVJlY29yZDo6RXJyb3JzBzoKQGJhc2VACjsi  
ewAi\nCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7\nAAY6CkB1c2VkewA=\n’,

`session_id` = ‘70cc8a35f2b959ac7b6a037fc52b5ed3’, `updated_at` =  
‘2006-03-29 13:22:09’ WHERE id = 965  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/connection\_adapters/abstract\_adapter.rb:120:in

`log’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/connection\_adapters/mysql\_adapter.rb:185:in

`execute’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/connection\_adapters/mysql\_adapter.rb:200:in

`update’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/base.rb:1717:in

`update\_without\_lock’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/locking.rb:33:in

`update\_without\_callbacks’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/callbacks.rb:274:in

`update\_without\_timestamps’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/timestamp.rb:39:in

`update’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/base.rb:1712:in

`create\_or\_update\_without\_callbacks’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/callbacks.rb:249:in

`create\_or\_update’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/base.rb:1388:in

`save\_without\_validation’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/validations.rb:724:in

`save\_without\_transactions’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/transactions.rb:126:in

`save’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/connection\_adapters/abstract/database\_statements.rb:51:in

`transaction’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/transactions.rb:91:in

`transaction’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/transactions.rb:118:in

`transaction’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/transactions.rb:126:in

`save’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/session/active\_record\_store.rb:307:in

`update’  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active\_record/base.rb:794:in

`silence’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/session/active\_record\_store.rb:307:in

`update’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/session/active\_record\_store.rb:314:in

`close' C:/ruby/lib/ruby/1.8/cgi/session.rb:330:in`close’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/base.rb:982:in

`close\_session’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/base.rb:1024:in

`process\_cleanup\_without\_flash’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/flash.rb:147:in

`process\_cleanup\_without\_filters’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/filters.rb:426:in

`process\_cleanup\_without\_session\_management\_support’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/session\_management.rb:126:in

`process\_cleanup\_without\_components’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/components.rb:182:in

`process\_cleanup’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/base.rb:383:in

`process\_without\_filters’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/filters.rb:364:in

`process\_without\_session\_management\_support’  
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action\_controller/session\_management.rb:117:in

`process' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/dispatcher.rb:38:in`dispatch’  
C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick\_server.rb:115:in  
`handle_dispatch' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:81:in`service’ C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in`run’  
C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in`start\_thread’  
C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in`start’  
C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in`start’  
C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick\_server.rb:67:in  
`dispatch’  
C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/servers/webrick.rb:59

C:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:21:in  
`require’  
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active\_support/dependencies.rb:136:in

`require' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/server.rb:30 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in`require’  
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active\_support/dependencies.rb:136:in

`require’ ./script/server:3 -e:3

---

<div class="post-metadata">

**Author:** ![lopmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/258eb7/32.png) [@lopmx](https://www.ruby-forum.com/u/lopmx)\
**Post date:** [March 29, 2006, 4:17pm UTC](https://www.ruby-forum.com/t/mysql-losts-connection-cant-refer-to-user/89912/2 "2006-03-29T16:17:45Z")

</div>

It looks like you may have a conflict with transaction-simple. If you  
have that gem installed, try uninstalling it. transaction-simple was  
upgraded to the current version in Rails 1.1, though it doesn’t  
include the whole library. In any case, that’s where I’d look.

-Tom

---

<div class="post-metadata">

**Author:** ![lopmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/258eb7/32.png) [@lopmx](https://www.ruby-forum.com/u/lopmx)\
**Post date:** [March 29, 2006, 4:51pm UTC](https://www.ruby-forum.com/t/mysql-losts-connection-cant-refer-to-user/89912/3 "2006-03-29T16:51:23Z")

</div>

Tom W. napisaÅ?(a):

> It looks like you may have a conflict with transaction-simple. If you  
> have that gem installed, try uninstalling it. transaction-simple was  
> upgraded to the current version in Rails 1.1, though it doesn’t  
> include the whole library. In any case, that’s where I’d look.
> 
> -Tom

Hmm, I have reinstalled whole ruby + rails to 1.8.4 and 1.1, don’t have  
any other gems installed. Could it be a problem with Windows platform  
incompatibility?

---

<div class="post-metadata">

**Author:** ![lopmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/258eb7/32.png) [@lopmx](https://www.ruby-forum.com/u/lopmx)\
**Post date:** [April 18, 2006, 6:08am UTC](https://www.ruby-forum.com/t/mysql-losts-connection-cant-refer-to-user/89912/4 "2006-04-18T06:08:11Z")

</div>

Piotr U. wrote:

> Tom W. napisaÅ?(a):
> 
> > It looks like you may have a conflict with transaction-simple. If you  
> > have that gem installed, try uninstalling it. transaction-simple was  
> > upgraded to the current version in Rails 1.1, though it doesn’t  
> > include the whole library. In any case, that’s where I’d look.
> > 
> > -Tom
> 
> Hmm, I have reinstalled whole ruby + rails to 1.8.4 and 1.1, don’t have  
> any other gems installed. Could it be a problem with Windows platform  
> incompatibility?

I have similar problems. Here is my setup:  
+InstantRails 1.3  
+RadRails 0.6.2  
+Windows 2000 Pro SP4 (With IIS-not running)

When using WEBrick it would crash every 4th or 5th operation. I could  
repeat it over and over using the same steps. I switched to using Apache  
and InstantRails’ SCGI server. With this setup it crashes much less but  
will still crash on occassion. It’s the Windows ruby.exe console window  
(running for SCGI) that crashes and must be continually restarted.

I’m not sure where the problem is. I presume it is a newer problem  
because when I was using RoR 1.0 (InstantRails 1.0) I never noticed  
these crashes. But I was brand new to RoR then too.

I hope there is something that can be done for improved Windows  
stability.

-Mark E.

---

<div class="post-metadata">

**Author:** ![lopmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/258eb7/32.png) [@lopmx](https://www.ruby-forum.com/u/lopmx)\
**Post date:** [April 18, 2006, 7:54am UTC](https://www.ruby-forum.com/t/mysql-losts-connection-cant-refer-to-user/89912/5 "2006-04-18T07:54:21Z")

</div>

On 4/17/06, Mark E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> (running for SCGI) that crashes and must be continually restarted.
> 
> I’m not sure where the problem is. I presume it is a newer problem  
> because when I was using RoR 1.0 (InstantRails 1.0) I never noticed  
> these crashes. But I was brand new to RoR then too.
> 
> I hope there is something that can be done for improved Windows  
> stability.
> 
> -Mark E.

Try deleting the file:

InstantRails\ruby\lib\ruby\site\_ruby\1.8\i386-msvcrt\mysql.so

This is the native C mysq binding for Ruby. If you delete this, then  
Rails will automatically use the pure Ruby driver instead.

There has been a report similar to yours where this solved the  
problem. Please let me know if this works.

Curt

---

<div class="post-metadata">

**Author:** ![lopmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/258eb7/32.png) [@lopmx](https://www.ruby-forum.com/u/lopmx)\
**Post date:** [April 18, 2006, 5:57pm UTC](https://www.ruby-forum.com/t/mysql-losts-connection-cant-refer-to-user/89912/6 "2006-04-18T17:57:08Z")

</div>

Curt H. wrote:

> On 4/17/06, Mark E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > (running for SCGI) that crashes and must be continually restarted.
> > 
> > I’m not sure where the problem is. I presume it is a newer problem  
> > because when I was using RoR 1.0 (InstantRails 1.0) I never noticed  
> > these crashes. But I was brand new to RoR then too.
> > 
> > I hope there is something that can be done for improved Windows  
> > stability.
> > 
> > -Mark E.
> 
> Try deleting the file:
> 
> InstantRails\ruby\lib\ruby\site\_ruby\1.8\i386-msvcrt\mysql.so
> 
> […]  
> Curt

Curt,

That seemed to fix it! Thanks! I haven’t had a crash since I remove that  
file. That makes me feel much better now about future development on  
RoR.

Thanks,  
-Mark E.
