Problem With PostgreSQL ODBC ZenPack

In my new job(if after 8 months you can count it as new!) I am responsible to maintain Zenoss and some week I am on call for Zenoss’s Alarm.

One of the strangest problem that we had was about PostgreSQL ODBC Database Monitor package. suddenly zenperfsql stopped without any log.

I tried to run zenperfsql in debug mode and I hoped that I would fix the problem. but after the daemon died again the error that I saw was :

python: pthread_mutex_lock.c:62: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed.

I never thought that I would face to python’s thread stuff ! as far as I knew Zenoss use Twisted framework and this error just happened for sql daemon so I reviewed the way that we had installed the packahe

For using this package you need to follow these steps

/usr/local/zenoss/python/bin/easy_install pyodbc apt-get install odbc-postgresq apt-get install unixodbc-dev

And edit /etc/odbcinst.ini, here is the tricky part, if you follow unixodbc document, it recommends you to config like :

[PostgreSQL] Description = PostgreSQL ODBC driver (Unicode version) Driver = /usr/lib/odbc/psqlodbca.so Setup = /usr/lib/odbc/libodbcpsqlS.so

But you need to add an other line which is specifying number of Threads

[PostgreSQL] Description = PostgreSQL ODBC driver (Unicode version) Driver = /usr/lib/odbc/psqlodbca.so Setup = /usr/lib/odbc/libodbcpsqlS.so Threading = 2

After adding Threading line I never face that problem, I dunno why Twisted which is built as asynchronous framework can not handle this and we need to limit ODBC’s Thread.


I found another blog that he faced same problem and he explains the reason (see more)