[sr-dev] git:master: acc: extended documentation for db_insert_mode parameter

Daniel-Constantin Mierla miconda at gmail.com
Wed Apr 16 11:11:31 CEST 2014


Hello,

On 16/04/14 10:48, Juha Heinanen wrote:
> Daniel-Constantin Mierla writes:
>
>> +   If set to 2, async insert is used if the db driver module has support
>> +   for it. If not, then standard INSERT is used.
>> +
>>      Default value is 0 (no INSERT DELAYED).
> daniel,
>
> just to clarity, is there some relationship between INSERT DELAYED and
> async insert?
No.

>    if db_insert_mode=2, is INSERT DELAYED or standard INSERT
> used?  that is, do db_insert_mode 0 and 2 somehow differ on the wire to
> db server or is it so that both 0 and 2 use standard INSERT?
Both use standard INSERT.

INSERT DELAYED is an extension of MySQL and doesn't work for all engines 
(e.g., innodb) and there are even plans to be removed, as I got it from 
some forums.

The async insert is based on a generic framework that can be extended to 
all other queries that don't return a db result needed in config or 
inside the module (e.g., delete, update -- on the todo list, trying to 
figure out if would be possible to do it via db api for all db modules 
at once).

In the recent commits I added the features of creating a dedicated group 
of processes (named async workers) that listen on an internal socket for 
tasks sent by other processes (e.g., sip workers, timers, etc.). These 
new processes are used also by the async_task_route() function.

The mechanism behind async insert is as follow:
- the INSERT query is printed by the process that does the db operation
- the mysql module instead of sending the query to mysql server, clones 
it in shared memory and sends it to the group of async workers
- one of the workers reads the task and sends the query to the database 
server

To have the above working, the db_url is also cloned and sent to async 
workers in order to identify the right connection to use. The first idle 
async worker is receiving the task (it is kernel based, the same 
mechanism used for many processes reading on the same UDP socket). You 
have to specify the number of async workers via global parameter 
async_workers:

- http://www.kamailio.org/wiki/cookbooks/devel/core#async_workers

Cheers,
Daniel

-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda




More information about the sr-dev mailing list