[freetds] Multiples connections is locking

Frediano Ziglio freddy77 at gmail.com
Wed Dec 16 07:52:27 EST 2009


2009/12/16 João Marcelo Loureiro do Amaral <joaomarcelobsb at gmail.com>:
> Hi Frediano, I need your help, please!
> I built an application using unixODBC with FreeTDS (SQLServer 2000). And I
> found a critical problem when I use multiple connections!
> I built a Stored Procedure in my BD that stays in slow loop, and I built an
> other Stored Procedure that returns very quickly.
> I created a thread (posix) to execute the first procedure, and I created an
> other thread to execute the second procedure (that returns fast).
> I am not sharing any handles between the threads (Enviroment, Connection or
> Statement) and I am not using mutex control, but the second thread locks
> when try to use any handle (Enviroment by example).
> First I created thread that executes slow procedure, and after 1 second, I
> create thread that executes fast procedure. But the second procedure only
> returns after the first ends.
> I built same example in ODBC32 and works well!
> Please help me!
> I am migrating from windows to linux, and I am needing this very much! Any
> help are welcome!
> Sorry by my english...
>

.... omissis ...

It's a known problem. By default unixODBC apply a threading model 3
that serialize every calls of a driver. It's safe to use a threading
of 1. To specify this however you have to use odbcinst.ini like

/etc/odbcinst.ini

[FreeTDS]
Driver = /path/to/our/libtdsodbc.so
Threading = 1

and in odbc specify the driver using odbcinst.ini, like

/etc/odbc.ini (or ~/.odbc.ini or another file with overriding)

[dsnname]
Driver = FreeTDS
Server = dns_server_name
Port = your_port
TDS_Version = 8.0

or use a connect string with driver parameter like

"DRIVER=FreeTDS;SERVER=dns_server_name;PORT=your_port;TDS_Version=8.0"

freddy77



More information about the FreeTDS mailing list