0

I'm experiencing what I believe is an environment issue, but I'm at my end as far as debugging it. I'm attempting to connect to a Sybase SqlAnywhere from a Rails 3.2.13 app on the same network. This is working from a rails 2.8 app, but I desperately need to upgrade.

It seems that I can connect through the rails console to the database the very first time that I create my new ruby gem and gemset using RVM, but subsequent attempts simply hang with no response after an attempt to query the database. I believe the database connection is being established as I get an error when incorrect credentials are supplied. After a successful connection on the first attempt, I am unable to replicate the success by opening a new terminal tab, setting the same gem and gemset, sourcing the database, and issuing the same query in the rails console.

I'm using a rails32 branch of a fork of the sqlanywhere adapter since the database adapter hasn't been supported by Sybase for a little while, but it has reported success using the same setup and I don't think this is the root of my issue since I've successfully returned valid data in the trials with limited success.

I've compared the working and non-working environments with no apparent difference, but is there anything significantly different about the RVM environment after the initialization of the gem/gemset that could be getting in the way?

  • Which version does it work on? Rails 2.8 doesnt exist so I guess you mean 2.3. Is everything working fine on your local development environment? Im unsure what exactly you mean by "I can connect through the rails console to the database the very first time that I create my new ruby gem and gemset using RVM, but subsequent attempts simply hang" Are you starting the console, everything looks fine, and then doing something like "User.count" make the console hang indefinitely? – Arctodus Jun 10 '13 at 14:06
  • Yes - it works currently on 2.3.5 (sorry for the typo!) with the standard sqlanywhere adapter. To clarify about the console, I create a new gem and gemset ruby-1.9.2-p320 (and I've tried various other patch levels), source the database, enter the rails console, perform User.count and it works great. I can issue as many additional activerecord commands and this session continues to work great. Then, I open a new terminal tab using the same project, gem and gem set, source the database, enter rails console, issue User.count and at that point it simply hangs - no response. – Brandon Burke Jun 10 '13 at 14:18
  • At that time I can even go back to the original rails console session that worked after creating the ruby&gemset, and it still works when I issue User.count. – Brandon Burke Jun 10 '13 at 14:19
  • Ok, so is the problem is that you cant keep more than one connection to the database at the same time? The first connection can be stopped and started as many times as you want right? – Arctodus Jun 10 '13 at 15:23
  • Not exactly, it doesn't seem to be related to the number of connections. I can terminate the connection in the 'original session' and restart it and get data back just fine, but I can't terminate the original session and get data back from the other session. Also, if I restart the computer and try again I can't get data back at all - it just hangs as it did before. – Brandon Burke Jun 10 '13 at 17:23
  • Ok, do you mind adding the database.yml config? (sensitive parts removed ofc). You said earlier that you "source the database". I dont really know what that means. I've always connected to a database server, both locally and in production. – Arctodus Jun 10 '13 at 19:05
  • Don't mind at all. It is the same as my working rails 2.3 app. [database.yml](https://gist.github.com/brandonburke/5756609#file-gistfile1-yml) – Brandon Burke Jun 11 '13 at 12:57
  • Don't mind at all. It is the same as my working rails 2.3 app. [Gist: database.yml](https://gist.github.com/brandonburke/5756609#file-gistfile1-yml) I maybe should have noted that this is a secondary database on the rails app. Again, that is working fine in my 2.3 app. I'm handling it by creating a class that my sqla models inherit from which inherits from ActiveRecord. This class establishes a connection to the sqlanywhere database. – Brandon Burke Jun 11 '13 at 13:04
  • What have you done to try and isolate the problem? Surely a lot more than the rails version have changed, since rails 3 is nowhere near backwards compatible with rails 2. Have you tried creating a separate vanilla rails 3.2 app with only one model to see if that works? Have you tried rails 3.0, which should be compatible with the last version created by the original adapter author? You could also do a test on Ruby 1.8.7, which rails 3.2 should work with. I have no idea what the problem is, or where it is, so I recommend you try some of these things to hopefully narrow down the possibilities. – Arctodus Jun 11 '13 at 19:14
  • Btw: I've spent a lot of time trying to figure out all sorts of issues getting Rails to cooperate with SQL Anywhere on Linux over the last few years. If migrating to a different database were an option I would have done it long ago. If that is an option at all for you I'd recommend you do it ASAP and save yourself from a lot of time waste and frustration in the coming years. There are very few people who use this tech stack, hence there are more problems and fewer sources to get help when you run into them. – Arctodus Jun 11 '13 at 19:27
  • I've tried to isolate as much as possible by creating new apps with single models. Have tested multiple versions of ruby and rails versions back to 3.1 with multiple patch levels. I've not tried 3.0, but was hoping to upgrade to 3.2. Sybase SQLAnywhere or anything for that matter isn't my tech stack of choice, and unfortunately changing isn't an option. I know it isn't a very supported path. Could you tell me the ruby version and rails release that you have working with your fork? I don't need to do much other than some basic finds and joins - hopefully I can get it there. – Brandon Burke Jun 12 '13 at 00:10
  • I've used my fork on multiple versions of Rails 3.1 and 3.2 and I have not had any issues like the one you describe. Problems I've come across have always been generation of incorrect SQL. Currently the only thing that I know of that doesnt work is the 3.2 "auto explain query"-feature. Have you tried installing sql anywhere developer edition locally and fire up a database server there? Maybe there's some sort of server config that causes this. – Arctodus Jun 12 '13 at 12:31
  • I've tried three different sqlanywhere database installations, but I've not tried connecting it to a local sqlanywhere database. I'll give that a shot, but I think it still has something to do with my environment. I have access to a completely fresh machine that I'll try as well. Thanks. – Brandon Burke Jun 13 '13 at 21:33
  • Did you figure this one out? If so Im just curious what the problem was :) – Arctodus Jun 21 '13 at 09:50
  • I've not yet, unfortunately. I haven't had the opportunity to try reproducing it on a fresh machine. I feel that will provide some additional insight. Still on rails 2.3 - (migrated to rails 2.3 LTS) for the time being. – Brandon Burke Jun 21 '13 at 13:46
  • I received a pull request the other day with an encoding fix. Probably wont solve your problem but worth a shot. https://github.com/Sharagoz/activerecord-sqlanywhere-adapter/commit/1cdd9ff59f966b27367f05f688b2a486d36ff5f2 – Arctodus Jun 26 '13 at 18:17
  • Yeah, I received a notification about it - thanks for thinking of me. Seems like a long shot, but I'm going to give that a try tonight. Thanks! – Brandon Burke Jun 26 '13 at 21:50

0 Answers0