[Kamailio-Devel] postgres queries overlapping
henning.westerholt at 1und1.de
Wed Jul 30 13:56:34 CEST 2008
On Wednesday 30 July 2008, Jason Penton wrote:
> >> 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.
i assume that you refer to the 1.3 branch (in 1.4 static buffer is placed in
the core DB API). Every worker children of the server has each own buffer, so
normally queries could not overlap, if every module behaves correctly. This
structure (with the static buffer) is basically used since the fork of
If some module does not free some results correctly, for example in error
conditions (see today thread on users), then this could cause the errors
you've described. Another issue is wrong initialization (for example in an
out of tree module), which caused the problems observed in past
thread "db_mysql commands out of sync" on devel. In this problem several
mysql connections shares the same thread_id, and thus queries overlapped.
The code in trunk could of course changed to set locks around the buffer, or
make this stuff non-static. But i'm not assured this fix the real cause of
the problem, it would also decrease performance. Even if the whole DB API was
made a little bit more abstract recently, it still avoids superflous work,
although if this could mean some lack of robustness in certain error
Do you could share some more details, for example error messages?
More information about the Devel