I found the issue.
Hopefully someone who's maintaining the kamailio db_postgres module can react to this.

According to the libpq documentation (see http://www.enterprisedb.com/documentation/libpq-concepts.html all the way at the bottom).

One thread restriction is that no two threads attempt to manipulate the same PGconn object at the same time. In particular, you cannot issue concurrent commands from different threads through the same connection object. (If you need to run concurrent commands, use multiple connections.)
I've been adding several debugging code to the db_postgres module, And I see that two different threads use two different _con variables,
but the _con->tail from separate threads are pointing both to same memory location, and using the same postgresql connection.
When multiple threads run at the same time and placing queries almost at the same time, it happens that the results of those queries are returned back to the other thread.

I don't know the kamailio code (Just started with kamailio 3 weeks back),
but it appears to me that the lib/srdb source is holding using some kind of pools for the database connections,
and db_postgres modules also is using pools.

I'm going to try to see if I can fix the code somehow that every thread gets its own database connection.
but if someone who knows the db_postgres module could help I would be very thankfull!


--
Exa-Omicron
Patroonsweg 10
3892 DB Zeewolde
Tel.: 088-OMICRON (66 427 66)
http://www.exa-omicron.nl
_______________________________________________ sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev


--
Exa-Omicron
Patroonsweg 10
3892 DB Zeewolde
Tel.: 088-OMICRON (66 427 66)
http://www.exa-omicron.nl