[Kamailio-Devel] postgres queries overlapping

Jason Penton jason.penton at smilecoms.com
Wed Jul 30 13:22:46 CEST 2008


Hi Klaus

On Wed, Jul 30, 2008 at 1:12 PM, Klaus Darilion <
klaus.mailinglists at pernau.at> wrote:

>
>
> 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?


it seems it is an issued becuase under high load the mysql buffer was beign
overwritten resulting in bad SQL queries. This continued until I put mutexes
around the static SQLQuery buffer in the mysql module. Maybe the
multi-porcess programmers can shed some light? I just thought that this may
be a similar probem to what the orginal poster is experiencing.

Cheers
Jason


>
>
> 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
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kamailio.org/pipermail/devel/attachments/20080730/0215b0d1/attachment.htm 


More information about the Devel mailing list