tiny_tds:分段错误

时间:2014-06-22 18:33:31

标签: ruby-on-rails azure-sql-database irb tiny-tds

这与此question类似。但是,发布在该问题上的answer对我不起作用。我在Mac上安装了freetds。我在GemFile中指定了以下内容。

gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', '~> 4.1.0'

我可以使用以下内容

连接到Azure SQL 成功
tsql -H host_name.database.windows.net -U user_name -D database_name -p 1433 -P password

我也可以在irb。

连接到Azure SQL 成功
require 'tiny_tds'
client = TinyTds::Client.new(:username => 'user_name@host_name', :password => 'password', :host =>'host_name.database.windows.net')

但是当我跑的时候, rake db:migrate 我收到以下错误,

[BUG] Segmentation fault at 0x007fff5f3ffff8
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]

然后是,

Control frame information
C level backtrace information
Other runtime information

最后,以

结尾
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap: 6

任何人都可以分享任何想法或建议吗?

更新:我的Database.yml看起来像,

development:
  #adapter: sqlite3
  #database: db/development.sqlite3
  #pool: 5
  #timeout: 5000
  adapter: sqlserver
  mode: dblib
  dataserver:
  host: host_name.database.windows.net
  port: 1433
  database: database_name
  username: user_name
  password: password
  timeout: 5000
  azure: true

我在IRB上运行了以下内容,

2.1.1 :028 > ActiveRecord::Base.establish_connection(
2.1.1 :029 >        :adapter  => "sqlserver",
2.1.1 :030 >        :host     => "host_name.database.windows.net",
2.1.1 :031 >        :username => "user_name",
2.1.1 :032 >        :password => "password",
2.1.1 :033 >        :database => "database_name"
2.1.1 :034?>    )

得到以下回复,

 => #<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00000101e8c798 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x00000101e8c748>, @spec=#<ActiveRecord::ConnectionAdapters::ConnectionSpecification:0x00000101f3ceb8 @config={:adapter=>"sqlserver", :host=>"host_name.database.windows.net", :username=>"user_name", :password=>"password", :database=>"database_name"}, @adapter_method="sqlserver_connection">, @checkout_timeout=5, @dead_connection_timeout=5, @reaper=#<ActiveRecord::ConnectionAdapters::ConnectionPool::Reaper:0x00000101e8c720 @pool=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00000101e8c798 ...>, @frequency=nil>, @size=5, @reserved_connections=#<ThreadSafe::Cache:0x00000101e8c6d0 @backend={}, @default_proc=nil>, @connections=[], @automatic_reconnect=true, @available=#<ActiveRecord::ConnectionAdapters::ConnectionPool::Queue:0x00000101e8c658 @lock=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00000101e8c798 ...>, @cond=#<MonitorMixin::ConditionVariable:0x00000101e8c630 @monitor=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00000101e8c798 ...>, @cond=#<Thread::ConditionVariable:0x00000101e8c608>>, @num_waiting=0, @queue=[]>> 

1 个答案:

答案 0 :(得分:1)

我会简化你的database.yml配置,剥离到基本要素。

development:
 adapter: sqlserver
 host: "host.database.windows.net"
 port: 1433
 database: <database>
 username: <username>
 password: <password>
 timeout: 5000

但首先尝试模拟通过IRB中的db:migrate任务发生的连接实例。

 ActiveRecord::Base.establish_connection(
   :adapter  => "sqlserver",
   :host     => "host.database.windows.net",
   :username => <username>,
   :password => <password>,
   :database => <database>
 ) 

如果成功,那么只使用database.yml中的那些值。如果需要添加更多配置值,请一次添加一个。虽然这些核心配置应该可以胜任。