0

Today we had a lot more activity than normal between our Ruby on Rails application and our remote legacy SQL Server 2005 database, and we started getting the error below intermittently. What is is? How can I prevent it (besides avoiding the situation, which we're working on)?

Error Message:

ActiveRecord::StatementInvalid: DBI::DatabaseError: 08S01 (20020) [unixODBC][FreeTDS][SQL Server] Bad token from the server: Datastream processing out of sync: SELECT * FROM [marketing] WHERE ([marketing].[contact_id] = 832085)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ryw
  • 9,375
  • 5
  • 27
  • 34

3 Answers3

1

You need to use some sort of connection pooling.

Windows itself (including Windows Server X) will only allow a certain number of socket connections to be created in a given time frame, even if you close them. All others will fail after that.

A connection pool will keep the same sockets open, avoiding the problem. Also, new connections are real slow.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
DaveTheC
  • 11
  • 1
0

This Microsoft article says:

Often caused by an abruptly terminated network connection, which causes a damaged Tabular Data Stream token to be read by the client.

Was the server network bound? I have no experience with SQL Server, but does it have a limit on the number of connections you can make?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
BJ Clark
  • 3,215
  • 2
  • 17
  • 16
-1

Add the following to your script; the first statement you run:

SET NO_BROWSETABLE OFF
Ryan K
  • 3,985
  • 4
  • 39
  • 42