<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I found the cause of my issue.<br>
<br>
In the source lib/srdb1/* some kind of pooling is used.<br>
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..).<br>
<br>
According to the PQ library every proces / thread should have it's
own database connection.<br>
The db_postgres is setup to use asynchronous I/O with the PQ
library.<br>
So when two threads are using the same database connection it is
possible that,<br>
the resultset from a query of thread A is returned to thread B.<br>
The cmp_db_id function in lib/srdb1/db_id.c does _not_ check the
PID.<br>
<br>
I've created a small patch to fix the problems mentioned above.<br>
<br>
The changes are made in lib/srdb1/* files<br>
So if you apply them, it will be active for _every_ database module.<br>
Maybe it's not needed for the mysql database,<br>
but I *assume* it will not break when used on a mysql database. (not
tested)<br>
Maybe you will get a bit more database connections, but that depends
on which modules you're using.<br>
<br>
What did I do:<br>
<ul>
<li>Added pid to the db_id struct.</li>
<li>During initialization the pid is saved into the db_id struct.</li>
<li>In cmp_db_id the pid is also checked when searching for a
database connection to be reused.</li>
</ul>
With kind Regards,<br>
Robert Verspuy<br>
<br>
<div class="moz-signature">-- <br>
<b>Exa-Omicron</b><br>
Patroonsweg 10<br>
3892 DB Zeewolde<br>
Tel.: 088-OMICRON (66 427 66)<br>
<a class="moz-txt-link-freetext" href="http://www.exa-omicron.nl">http://www.exa-omicron.nl</a></div>
</body>
</html>