[unixODBC-support] CPReuse

Matt Phipps matt.the.mech at gmail.com
Thu Mar 13 21:05:00 GMT 2014


Hi UnixODBC Support,

Our DBAs are telling us our connections are not getting closed properly, so
we're going through our various configs and trying to figure out what's
going on. This is a Python 2.7 Flask web app on an Ubuntu 12.04 machine,
using Flask-SQLAlchemy, SQLAlchemy, pyodbc, UnixODBC, and FreeTDS,
connecting to SQL Server 2008. The UnixODBC version for Ubuntu 12.04 is
2.2.14p2-5ubuntu3.

Obviously we're up to our ears in knobs to turn so we're trying to narrow
some down. Our UnixODBC config is pretty simple AFAIK:

odbcinst.ini:
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
FileUsage = 1
CPTimeout = 5
CPReuse = 5
client charset = UTF-8

odbc.ini:
[EchoOptimizer]
Description = "EchoOptimizer ODBC connection via FreeTDS"
Driver = FreeTDS
Server = <redacted>
Port = 1206
Database = EchoOptimizer
tds_version = 8.0

And we connect with a string like this:
DSN=EchoOptimizer;APP=bridge-it;PWD=<redacted>;UID=<redacted>;DATABASE=EchoOptimizer

There are a few things I'm pretty sure are cruft (these files were
committed some months ago by another dev): the "client charset" in
odbcinst.ini I think is a FreeTDS option that doesn't belong there, and the
DATABASE option in our connection string seems redundant.

However, one option is puzzling me: CPReuse. I see it all over the place on
the UnixODBC and FreeTDS mailing lists, but no one seems to know/care what
it does, and I'd kind of like to since it seems to affect connection
pooling and the lifecycle of our connections is what's under debate :) I
looked at the UnixODBC code and saw where the value was written by the QT
GUI, and I also found the following line:

#define ODBC_HELP_DRIVER_CPREUSE "The maximum number of times a connection
can be reused in a Connection Pool. Set to a lower number when dealing with
drivers which have stability issues or memory leaks."

But I didn't find anywhere in the code that reads this value...so yeah, I'm
confused. Does this value do anything? Would twiddling it (or CPTimeout)
change how long our connections stay open?

Thanks,
Matt Phipps
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20140313/af354cc7/attachment.html>


More information about the unixODBC-support mailing list