Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

MySQL: 'Packets out of order 2<>1' for Ruby binding

 
SOLVED
Go to solution
Ben Armstrong
Regular Advisor

MySQL: 'Packets out of order 2<>1' for Ruby binding

Whether I use an old MySQL I had lying around (4.0.13) or 5.1.11-beta which we just installed, when I try to do a very simple test of the Ruby bindings for MySQL I get this error:

my = Mysql::new("localhost","root","xxxxxx","testdb")
RuntimeError: Packets out of order: 2<>1
from ./mysql.rb:1019:in `read'
from ./mysql.rb:444:in `read'
from ./mysql.rb:130:in `real_connect'
from ./mysql.rb:91:in `initialize'
from (irb):2:in `new'
from (irb):2

Now, I don't expect anyone else uses Ruby on VMS, but I wonder if other language bindings (e.g. Perl) work, and if so, how? I don't know where to begin debugging. I took a brief look at the code where the error occurs but it was not obvious what might be wrong:

def read()
buf = []
len = nil
@sock.sync = false
while len == nil or len == MAX_PACKET_LENGTH do
a = @sock.read(4)
len = a[0]+a[1]*256+a[2]*256*256
pkt_nr = a[3]
if @pkt_nr != pkt_nr then
raise "Packets out of order: #{@pkt_nr}<>#{pkt_nr}"
end
@pkt_nr = @pkt_nr + 1 & 0xff
buf << @sock.read(len)
end
@sock.sync = true
buf.join
end


I see that in mysql.rb the Unix socket is defaulted to /tmp/mysql.sock. Now, surely Unix sockets don't work on VMS. Could this be related to my problem?

The setup program for this package attempts to determine the correct value with:

mysql_config --socket

but the VMS implementation of MySQL doesn't seem to have this utility.

Ben
7 REPLIES 7
Craig A Berry
Honored Contributor
Solution

Re: MySQL: 'Packets out of order 2<>1' for Ruby binding

This does not appear to be a VMS-specific problem. There are a *lot* of suggestions here:

http://tinyurl.com/6h9kok

but most of them must be wrong or there wouldn't be so many. The two I thought were most interesting were:

1.) replacing 'localhost' with 127.0.0.1 to make sure you follow the TCP/IP socket code path rather than the one for UNIX domain sockets. This is in a part of the code you did not quote:

if (host == nil or host == "localhost") and defined? UNIXSocket then

If the UNIXSocket extension (or plug-in or whatever you call them in Ruby) is present, it just might be defined even if the infrastructure it would need to work is not there.

2.) The other thing at the link cited above that was at least intriguing if kind of scary is changing the settings that control byte order to use network rather than native order. I could be wrong but I have the impression MySQL uses the same byte order on all platforms in order to make databases portable, but Ruby would almost surely use native ints, so this could involve fiddling.

There appear to be at least three MySQL bindings for Ruby, one of which uses the client library that ships with the database to do this sort of low-level byte shuffling; my money would be on that one rather than the pure-Ruby solution. Most likely there is an ODBC option as well.

As far as Perl goes, the usual path is the DBI library with the appropriate DBD extension. I've never used DBD::MySQL, but don't know of any reason it wouldn't work. I use DBD::Sybase with some frequency.


Jean-François Piéronne
Trusted Contributor

Re: MySQL: 'Packets out of order 2<>1' for Ruby binding

Python on OpenVMS include the MySQL module and run without any problem. It is used by on production system without any problem. It is also used for student's projects which are known to stress system :-)

Also 5.1.11 is fairly old there is a port of 5.1.22 on IA64 and 5.1.23 on AXP. We are working on a release of 5.1.23 IA64 kit, but I don't have any schedule.
You can take a look at
http://vmsmysql.dyndns.org/


mysql_config is a shell script which has not (yet?) been ported
If someone want to translate it into DCL he is welcome :-)


JF
Jean-François Piéronne
Trusted Contributor

Re: MySQL: 'Packets out of order 2<>1' for Ruby binding

I forgot to mention that PHP has also a MySQL module which work without any know specific MVS problem.

JF
labadie_1
Honored Contributor

Re: MySQL: 'Packets out of order 2<>1' for Ruby binding

Hello

>>>mysql_config is a shell script which has not (yet?) been ported
If someone want to translate it into DCL he is welcome :-)

May be you should install GNV
http://gnv.sourceforge.net/

and just run mysql_config in gnv on your Vms ?
Ben Armstrong
Regular Advisor

Re: MySQL: 'Packets out of order 2<>1' for Ruby binding

Great suggestions. Thanks! The Rails site is down right now but i'll look at that page later (or look for the Google cache of it).

As for the new version, I had wondered if that were ready. I didn't find it easy to locate. I'll see if we can upgrade. Are there specific issues with the older release you can think of that I should watch out for? I'd like to know now if I can proceed with testing on this older version to decide if we're going to be successful before investing further resources to this project, or if I should upgrade immediately.

GNV? Sounds like overkill :) But yeah, we have GNV lying around. Still, a DCL translation of the script would be better.
Ben Armstrong
Regular Advisor

Re: MySQL: 'Packets out of order 2<>1' for Ruby binding

I tried replacing localhost with 127.0.0.1. No joy. As for using the C implementation, I read the prerequisites here:

http://www.tmtm.org/en/mysql/ruby/

* MySQL 5.0.51a
* Ruby 1.8.6, 1.9.0

We have the first one covered with jfp's beta, but the second could only be satisfied with JRuby at this time, and we're not ready to go there yet. So things are not looking good.
Willem Grooters
Honored Contributor

Re: MySQL: 'Packets out of order 2<>1' for Ruby binding

On JPF's remark on PHP's MySQL engine: be aware that, AFAIK, this it;s based on MySQL 3! On JFP's MySQL forum there is a descrioption how to build a MySQL 4.1 engine for PHP.
Willem Grooters
OpenVMS Developer & System Manager