jeremyevans / sequel

Sequel: The Database Toolkit for Ruby
http://sequel.jeremyevans.net
Other
4.97k stars 1.07k forks source link

Error: 'connect': TinyTds::Error: Adaptive Server connection failed (127.0.0.1) (Sequel::DatabaseConnectionError) when second script instance tries to connect to MS-SQL #2037

Closed seydel1847 closed 1 year ago

seydel1847 commented 1 year ago

Complete Description of Issue

I am running two instances of script connecting to MS-SQL database. The first is connected. The second is either rejected with error: `connect': TinyTds::Error: Adaptive Server connection failed (127.0.0.1) or it may hang up completely and I need to kill terminal.

Simplest Possible Self-Contained Example Showing the Bug

require "sequel" require 'tiny_tds'

db_connection_params = { :adapter => 'tinytds', :host => '127.0.0.1', :port => '1434', :database => 'xxx', :user => 'xxx', :password => 'xxx', :timeout => 600 }

@db = Sequel.connect(db_connection_params)

while true print '.' puts @db.test_connection sleep(1)
end

Full Backtrace of Exception (if any)

c:/R/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tiny_tds-2.1.5/lib/tiny_tds/client.rb:60:in connect': TinyTds::Error: Adaptive Server connection failed (127.0.0.1) (Sequel::DatabaseConnectionError) from c:/R/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tiny_tds-2.1.5/lib/tiny_tds/client.rb:60:ininitialize' from k:/code_workspace/research/gems/sequel/sequel/adapters/tinytds.rb:25:in new' from k:/code_workspace/research/gems/sequel/sequel/adapters/tinytds.rb:25:inconnect' from k:/code_workspace/research/gems/sequel/sequel/database/connecting.rb:280:in new_connection' from k:/code_workspace/research/gems/sequel/sequel/connection_pool.rb:162:inmake_new' from k:/code_workspace/research/gems/sequel/sequel/connection_pool/single.rb:28:in hold' from k:/code_workspace/research/gems/sequel/sequel/database/connecting.rb:331:insynchronize' from k:/code_workspace/research/gems/sequel/sequel/database/connecting.rb:340:in test_connection' from k:/code_workspace/research/gems/sequel/sequel/database/misc.rb:188:ininitialize' from k:/code_workspace/research/gems/sequel/sequel/database/connecting.rb:68:in new' from k:/code_workspace/research/gems/sequel/sequel/database/connecting.rb:68:inconnect' from k:/code_workspace/research/gems/sequel/sequel/core.rb:124:in connect' from con_test.rb:40:in

'

SQL Log (if any)

No response

Ruby Version

ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x64-mingw32]

Sequel Version

sequel (5.67.0, 5.42.0), tiny_tds (2.1.5, 2.1.4, 2.1.3)

seydel1847 commented 1 year ago

When I do the same using tiny_tds and TinyTds::Client.new then it works like a hell. I started to trace some sequel methods with puts "#{self.object_id} / #{self.class} / #{method}" and error appears somewhere after '860 / Module / synchronize'.

seydel1847 commented 1 year ago

It was my fault. I have used wrong port on MS-SQL when taking sequel snippet from the web.