[sr-dev] [tracker] Task opened: pooling of libsrdb1 doesnt restrict database connection to 1 thread and gives issues with postgresql (Attachment added)

sip-router admin at sip-router.org
Thu Oct 21 18:07:11 CEST 2010


THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

A new Flyspray task has been opened.  Details are below. 

User who did this - Robert Verspuy (exarv) 

Attached to Project - sip-router
Summary - pooling of libsrdb1 doesnt restrict database connection to 1 thread and gives issues with postgresql
Task Type - Bug Report
Category - libsrdb1 (kamailio)
Status - Assigned
Assigned To - Henning Westerholt
Operating System - Linux
Severity - High
Priority - Normal
Reported Version - 3.1
Due in Version - Undecided
Due Date - Undecided
Details - In the source lib/srdb1/* some kind of pooling is used.
When kamailio needs a database connection, the cmp_db_id function checks to see if there is already a database connection with the exact same params (username, database, server etc..).

According to the PQ library every proces / thread should have it's own database connection.
The db_postgres is setup to use asynchronous I/O with the PQ library.
So when two threads are using the same database connection it is possible that,
the resultset from a query of thread A is returned to thread B.
The cmp_db_id function in lib/srdb1/db_id.c does _not_ check the PID.

I've created a small patch to fix the problems mentioned above.

The changes are made in lib/srdb1/* files
So if you apply them, it will be active for _every_ database module.
Maybe it's not needed for the mysql database,
but I *assume* it will not break when used on a mysql database. (not tested)
Maybe you will get a bit more database connections, but that depends on 
which modules you're using.

What did I do:

    * Added pid to the db_id struct.
    * During initialization the pid is saved into the db_id struct.
    * In cmp_db_id the pid is also checked when searching for a database
      connection to be reused.

See complete thread on http://lists.sip-router.org/pipermail/sr-dev/2010-October/009689.html

One or more files have been attached.

More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=97

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.



More information about the sr-dev mailing list