I'm having an issue using FreeTDS.
We are running RHEL5 and are using unixODBC 2.2.14-p2, FreeTDS .82
stable (I've tried .83 dev with same results) and MS SQL Server 2005
with database compatibility mode set to 80. The application
interfacing to FreeTDS is an indexing tool so it opens multiple
threads and has lots of communication with the database. We
consistently receive an error, usually in the first 10 minutes, but
sometimes it can take half an hour.
The main application we are running will return this error output.
{sql.c 2641} Query: UPDATE links SET valid='f' WHERE ot=227236 and ot != k
SQL-server message: [unixODBC][FreeTDS][SQL Server]Read from server
failed[unixODBC][FreeTDS][SQL Server]Read from server failed.
After the error occurs I can run the failed statement directly against
SQL Server using management studio or using tsql and the command
always works.
This is our odbcinst.ini file.
[FreeTDS]
Description = FreeTDS Driver for MSSQL
Driver = /usr/local/lib/libtdsodbc.so.0
Version = 8.0
Setup = /usr/local/lib/libtdsodbdS.so.0
Threading = 3, 2, 1 (we've tried all versions, but the tds_output
below was created with 2)
Below is a snippet of the TDS DUMP file near the point of interest. I
can post more of the log file as requested.
mem.c:563:tds_free_all_results()
util.c:162:Changed query state from IDLE to QUERYING
write.c:136:tds_put_string converting 54 bytes of "UPDATE links SET
valid='f' WHERE ot=227241 AND ot != k"
write.c:164:tds_put_string wrote 108 bytes
util.c:162:Changed query state from QUERYING to PENDING
net.c:779:Sending packet
0000 01 01 00 74 00 00 01 00-55 00 50 00 44 00 41 00 |...t.... U.P.D.A.|
0010 54 00 45 00 20 00 6c 00-69 00 6e 00 6b 00 73 00 |T.E. .l. i.n.k.s.|
0020 20 00 53 00 45 00 54 00-20 00 76 00 61 00 6c 00 | .S.E.T. .v.a.l.|
0030 69 00 64 00 3d 00 27 00-66 00 27 00 20 00 57 00 |i.d.=.'. f.'. .W.|
0040 48 00 45 00 52 00 45 00-20 00 6f 00 74 00 3d 00 |H.E.R.E. .o.t.=.|
0050 32 00 32 00 37 00 32 00-34 00 31 00 20 00 41 00 |2.2.7.2. 4.1. .A.|
0060 4e 00 44 00 20 00 6f 00-74 00 20 00 21 00 3d 00 |N.D. .o. t. .!.=.|
0070 20 00 6b 00 - | .k.|
token.c:495:tds_process_tokens(0xa6e97b0, 0xb28cb694, 0xb28cb690, 0x6914)
util.c:162:Changed query state from PENDING to READING
util.c:334:tdserror(0xa6e9748, 0xa6e97b0, 20004, 104)
odbc.c:2032:msgno 20004 20003
util.c:368:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:389:tdserror: returning TDS_INT_CANCEL(2)
util.c:162:Changed query state from READING to DEAD
token.c:510:processing result tokens. marker is 0()
token.c:108:tds_process_default_tokens() marker is 0()
token.c:111:leaving tds_process_default_tokens() connection dead
util.c:110:logic error: cannot change query state from DEAD to PENDING
odbc.c:3269:odbc_process_tokens: tds_process_tokens returned 0
odbc.c:3270: result_type=4055, TDS_DONE_COUNT=10, TDS_DONE_ERROR=0
odbc.c:3119:_SQLExecute: odbc_process_tokens returned result_type 4048
odbc.c:3192:SQLExecute: bad results
error.c:609:SQLGetDiagRec(3, 0xa7208d0, 1, 0xb28cb72a, 0xb28cb738,
0xb28cb52a, 512, 0xb28cb734)
error.c:510:_SQLGetDiagRec(3, 0xa7208d0, 1, 0xb28cb72a, 0xb28cb738,
0xb28cb52a, 512, 0xb28cb734)
error.c:609:SQLGetDiagRec(3, 0xa7208d0, 2, 0xb28cb72a, 0xb28cb738,
0xb28cb52a, 512, 0xb28cb734)
error.c:510:_SQLGetDiagRec(3, 0xa7208d0, 2, 0xb28cb72a, 0xb28cb738,
0xb28cb52a, 512, 0xb28cb734)
odbc.c:3680:SQLFreeHandle(3, 0x0xa7208d0)
odbc.c:3769:_SQLFreeStmt(0xa7208d0, 1, 0)
odbc.c:1504:SQLAllocStmt(0xa6fed30, 0xb5d0bb00)
odbc.c:1403:_SQLAllocStmt(0xa6fed30, 0xb5d0bb00)
odbc.c:4079:SQLGetStmtAttr(0xb5d48840, 10010, 0xaf4c9858, 4, (nil))
odbc.c:3917:_SQLGetStmtAttr(0xb5d48840, 10010, 0xaf4c9858, 4, (nil))
odbc.c:4079:SQLGetStmtAttr(0xb5d48840, 10011, 0xaf4c9858, 4, (nil))
odbc.c:3917:_SQLGetStmtAttr(0xb5d48840, 10011, 0xaf4c9858, 4, (nil))
odbc.c:4079:SQLGetStmtAttr(0xb5d48840, 10012, 0xaf4c9858, 4, (nil))
odbc.c:3917:_SQLGetStmtAttr(0xb5d48840, 10012, 0xaf4c9858, 4, (nil))
odbc.c:4079:SQLGetStmtAttr(0xb5d48840, 10013, 0xaf4c9858, 4, (nil))
odbc.c:3917:_SQLGetStmtAttr(0xb5d48840, 10013, 0xaf4c9858, 4, (nil))
odbc.c:3205:SQLExecDirect(0xb5d48840, 0xaf4ca400, -3)
odbc.c:2965:_SQLExecute(0xb5d48840)
odbc.c:2970:_SQLExecute() starting with state 0
mem.c:563:tds_free_all_results()
util.c:162:Changed query state from IDLE to QUERYING
write.c:136:tds_put_string converting 54 bytes of "UPDATE links SET
valid='f' WHERE ot=227331 AND ot != k"
write.c:164:tds_put_string wrote 108 bytes
util.c:162:Changed query state from QUERYING to PENDING
net.c:779:Sending packet
0000 01 01 00 74 00 00 01 00-55 00 50 00 44 00 41 00 |...t.... U.P.D.A.|
0010 54 00 45 00 20 00 6c 00-69 00 6e 00 6b 00 73 00 |T.E. .l. i.n.k.s.|
0020 20 00 53 00 45 00 54 00-20 00 76 00 61 00 6c 00 | .S.E.T. .v.a.l.|
0030 69 00 64 00 3d 00 27 00-66 00 27 00 20 00 57 00 |i.d.=.'. f.'. .W.|
0040 48 00 45 00 52 00 45 00-20 00 6f 00 74 00 3d 00 |H.E.R.E. .o.t.=.|
0050 32 00 32 00 37 00 33 00-33 00 31 00 20 00 41 00 |2.2.7.3. 3.1. .A.|
0060 4e 00 44 00 20 00 6f 00-74 00 20 00 21 00 3d 00 |N.D. .o. t. .!.=.|
0070 20 00 6b 00 - | .k.|
There is a logic error in the output above, but I don't know if it's internal to FreeTDS or elsewhere.
Once the above error occurs, it is a domino affect and then occurs for
every indexing thread and the program terminates.