[Freeswitch-users] mod_crd_sqlite entry limit and sqlite segfaults on triggers

Neven Boric nboric at yx.cl
Tue Apr 26 01:00:33 MSD 2011


Hi,

By looking at the code, I believe there is no limit on the number of 
rows mod_cdr_sqlite will add to the cdr table. This could lead to 
(eventually) eating all RAM if you DB is in tmpfs or eating all disk 
space if it is stored on disk. Is this correct or am I missing something?

To correct this I tried to add a trigger to the table along the lines of:

CREATE TRIGGER IF NOT EXISTS CDR_LIMIT AFTER INSERT ON cdr
BEGIN
     DELETE FROM crd WHERE rowid <= (SELECT MAX(rowid) from cdr) - 100000;
END

and no matter how I try to add the trigger, I get a segmentation fault 
when the code calls sqlite3_exec in switch_core_db_exec.

Currently I'm blaiming SQLite, as there is a somewhat similar issue 
involving triggers reported for versions older than 3.5.4 (FS is using 
3.3.13)

http://sqlite.org/cvstrac/wiki?p=DatabaseCorruption

Of course I could just execute the delete statement manually after every 
insert, but it is uglier (more costly, non atomic).

Has anyone any experience using triggers with the sqlite version 
included in FS? Or has anyone tried other solution to limit the number 
on entries on the cdr table?

Thanks in advance
Neven Boric





More information about the FreeSWITCH-users mailing list