[Kamailio-Devel] postgres queries overlapping

Klaus Darilion klaus.mailinglists at pernau.at
Wed Jul 30 13:12:18 CEST 2008



Jason Penton schrieb:
> Hi All,
> 
> one thing I noticed in the mysql module (may be similar in postrges) is 
> that a static char array is used to build the sql query. This is however 
> NOT thread safe as we saw on multiprocessor Solaris boxes. Basically 2 

Kamailio does not use threads, but processes. Is this also an issue in 
multi-process applications?

regards
klaus


> threads were overwriting and corrupting the SQL query that was 
> eventually sent to the DB (obv. causing errors).
> 
> 2 ways to solve this are:
> 
> 1. put mutexes around the shared SQL buffer
> 2. dont use static space (obv. this is going to use more memory.
> 
> Cheers
> Jason
> 
> On Tue, Jul 29, 2008 at 10:12 PM, H Quintana <hjqlopez at yahoo.com 
> <mailto:hjqlopez at yahoo.com>> wrote:
> 
>     Hi dear developers,
> 
> 
>     I just upgraded from 1.2.2 to 1.3.2 and I'm getting a postgres error
>     because the DELETE query (delete from location where expires...) is
>     overlapped with a previous INSERT in the accounting table.
> 
>     I did some changes in postgres/dbase.c to always set the end of the
>     string for pg_delete, pg_update, pg_query, as it is for pg_insert.
>      I dont know if that is the best solution but it's working for me.
> 
>     Please let me know if that was ok or there is a better way to fix it.
> 
> 
>     Thanks for your time,
> 
>     Humberto
> 
> 
>     *******The problem's log*******
> 
> 
>     Jul 29 13:06:01 localhost /usr/local/sbin/openser[4730]:
>     WARNING:postgres:pg_get_result: 0x8193ef0 Probable invalid query
> 
>     Jul 29 13:06:01 localhost /usr/local/sbin/openser[4730]:
>     WARNING:postgres:pg_get_result: 0x8193ef0: PGRES_FATAL_ERROR
> 
>     Jul 29 13:06:01 localhost /usr/local/sbin/openser[4730]:
>     WARNING:postgres:pg_get_result: 0x8193ef0: ERROR:  syntax error at
>     or near "_from" LINE 1: ...07-29 13:06:02' AND expires!='1969-12-31
>     19:00:00'_from,sip_...                                              
>                    ^
> 
>     Jul 29 13:06:01 localhost /usr/local/sbin/openser[4730]:
>     WARNING:postgres:pg_delete: 0x8193ef0 Query: delete from location
>     where expires<'2008-07-29 13:06:02' AND expires!='1969-12-31
>     19:00:00'_from,sip_to,i_uri,o_uri,from_uri,to_uri,username,domain,hunt,invite_time,ringing_time
>     ) values ('INVITE','e5326044ad106ef2', ...
> 
> 
>     **********My solution(?) ********
> 
>     [root at localhost postgres]# diff dbase.c dbase.c.orig
>     656d655
>     <       *(_s + off) = '\0';
>     852d850
>     <       *(_s + off) = '\0';
>     895a894
>      >               *(_s + off) = '\0';
>     897d895
>     <       *(_s + off) = '\0';
> 
> 
> 
> 
> 
> 
> 
> 
>     _______________________________________________
>     Devel mailing list
>     Devel at lists.kamailio.org <mailto:Devel at lists.kamailio.org>
>     http://lists.kamailio.org/cgi-bin/mailman/listinfo/devel
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Devel mailing list
> Devel at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/devel



More information about the Devel mailing list