brianmario / mysql2

A modern, simple and very fast Mysql library for Ruby - binding to libmysql
http://github.com/brianmario/mysql2
MIT License
2.25k stars 550 forks source link

Strange startup error using mysql2 on windows #1020

Open Nilpointer opened 5 years ago

Nilpointer commented 5 years ago

Environment: Windows Server 2012 R2 Ruby: 2.5.3 (32 bit) Rails: 5.1.6.1 mysql2: 0.5.2 Hosted in iis with HttpPlattformHandler wrapping puma 3.11.4 mysql Server Version 5.5 running on different machine

I use a simple Table "roles" with only name and id and only 6 entries

Firing up rails console and querying

Role.find_by_name('m2m').id

results on the first try in ActiveRecord::StatementInvalid (Mysql2::Error: Unknown MySQL error: SELECT roles.* FROM roles WHERE roles.name = 'machine2machine' LIMIT 1)

results on the second try in ActiveRecord::StatementInvalid (Mysql2::Error::ConnectionError: Lost connection to MySQL server during query: SELECT roles.* FROM.....

and from the third run onward it starts to work always as expected

Starting the rails console again, the behavior starts over again with the same errors.

If I query instead Role.where(name: 'm2m').first.id It works from the first run onwards.

Any clues what could go wrong here?

Regards Andreas

sodabrew commented 4 years ago

I'm looking through stale issues to update or close. Were you ever able to sort out this issue?