Connecting to SQL-Azure in rails using tiny_TDS: [BUG] Segmentation fault

这一生的挚爱 提交于 2019-12-11 04:48:51

问题


We're trying to get rails to talk to a sqlserver db on Azure, we install freeTDS with openssl and libiconv:

./configure --prefix=/usr/local --with-libiconv-prefix=DIR --with-openssl=DIR
make
make install

We then add tiny_TDS and activerecord-sqlserver-adapter to the gemfile:

gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'

$ bundle install

Configure the database:

development:  
  adapter: sqlserver
  host: xxxxxxx.database.windows.net
  mode: DBLIB
  port: 1433
  database: xxxxx
  username: xxxxxxxx
  password: x
  azure: true

Run the server:

$ rails s

Everything works great up until this point, but as soon as you visit the site ruby crashes.

steven@jenny:~/irr$ rails server -p 3001
=> Booting WEBrick
=> Rails 3.0.4 application starting in development on http://0.0.0.0:3001
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-07-24 15:37:00] INFO  WEBrick 1.3.1
[2012-07-24 15:37:00] INFO  ruby 1.9.2 (2012-02-14) [x86_64-linux]
[2012-07-24 15:37:00] INFO  WEBrick::HTTPServer#start: pid=7586 port=3001
/home/steven/.rvm/gems/ruby-1.9.2-p318/gems/tiny_tds-0.5.1/lib/tiny_tds/client.rb:68: [BUG] Segmentation fault
ruby 1.9.2p318 (2012-02-14 revision 34678) [x86_64-linux]

-- control frame ----------
c:0048 p:---- s:0232 b:0232 l:000231 d:000231 CFUNC  :connect
c:0047 p:0429 s:0228 b:0228 l:000227 d:000227 METHOD /home/steven/.rvm/gems/ruby-1.9.2-p318/gems/tiny_tds-0.5.1/lib/tiny_tds/client.rb:68

We've tried several versions of ruby: 1.9.2-p318, 1.9.2-p320, 1.9.3-p125. Same error with all of them.

This is on ubuntu 11.10 using rvm and FreeTDS-0.9.1.

Any Ideas on a workaround?

Have I made an error somewhere along the way?

Edit

Output from IRB:

require 'tiny_tds'
client = TinyTds::Client.new(:username =>'XXXXX@XXXXXXX.database.windows.net', :password => 'XXXXXXX', :host => 'XXXXXX.database.windows.net',  :mode => 'DBLIB', :azure => 'true')
SystemStackError: stack level too deep from /home/martinr/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/irb/workspace.rb:80
Maybe IRB bug!!

It seems to be a bug with ruby itself:

/home/martinr/.rvm/gems/ruby-1.9.2-p320/gems/tiny_tds-0.5.1/lib/tiny_tds/client.rb:68: [BUG] Segmentation fault (core dumped)

回答1:


You should just do a simple IRB prompt and do something like this mentioned on the TinyTDS read me.

require 'tiny_tds' client = TinyTds::Client.new(...)

Fill in your connection params. Simple stuff like username, password, and host. Let me know how things go.

  • https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-Azure
  • https://github.com/rails-sqlserver/tiny_tds#using-tinytds-with-azure



回答2:


The error seems to be caused by having a username username@servername

When you remove the @severname part, ruby no longer crashes



来源:https://stackoverflow.com/questions/11632743/connecting-to-sql-azure-in-rails-using-tiny-tds-bug-segmentation-fault

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!