dOpensource/dsiprouter

Database error writing 'acc' logs

Closed this issue · 0 comments

Kamailio generates errors in writing data to the acc table due to the incompatible field types.
Specifically, the src_gwgroupid field is being passed with no data.

Nov  4 18:02:59 dsip1 /usr/sbin/kamailio[1203]: NOTICE: acc [acc.c:279]: acc_log_request(): ACC: transaction answered: timestamp=1667584979;method=INVITE;from_tag=658eb3d5-c36c-439a-986c-27690883e71c;to_tag=gK04bfcd3c;call_id=bb58123a-ca62-4add-9ee1-7037cf69711b;code=200;reason=OK;src_user=CUSTOMER;src_domain=sip.company.com;src_ip=XX.XX.XX.XX;dst_ouser=18005551212;dst_user=18005551212;dst_domain=us-west-or.sip.flowroute.com;calltype=outbound;src_gwgroupid=;dst_gwgroupid=21
Nov  4 18:02:59 dsip1 /usr/sbin/kamailio[1203]: ERROR: db_mysql [km_dbase.c:122]: db_mysql_submit_query(): driver error on query: Incorrect integer value: '' for column `kamailio`.`acc`.`src_gwgroupid` at row 1 (1366)
Nov  4 18:02:59 dsip1 /usr/sbin/kamailio[1203]: ERROR: <core> [db_query.c:244]: db_do_insert_cmd(): error while submitting query
Nov  4 18:02:59 dsip1 /usr/sbin/kamailio[1203]: ERROR: acc [acc.c:477]: acc_db_request(): failed to insert into database

These database fields src_gwgroupid and dst_gwgroupid are additional fields added by the dSIP platform to the standard kamailio.acc table and are set with a datatype of INT causing the source of the failure.

These can not be set to allow NULL because MySQL will not honor the src_gwgroupid=; to set to NULL because the parameter was passed, so they must be set to VARCHAR.

These fields are also present in kamailio.cdrs.

A quick fix to this is to alter the tables.

ALTER TABLE `acc` CHANGE `src_gwgroupid` `src_gwgroupid` VARCHAR(10)  NULL  DEFAULT '0';
ALTER TABLE `acc` CHANGE `dst_gwgroupid` `dst_gwgroupid` VARCHAR(10)  NULL  DEFAULT '0';
ALTER TABLE `cdrs` CHANGE `src_gwgroupid` `src_gwgroupid` VARCHAR(10)  NULL  DEFAULT '0';
ALTER TABLE `cdrs` CHANGE `dst_gwgroupid` `dst_gwgroupid` VARCHAR(10)  NULL  DEFAULT '0';

This will assure that any issues with query fields that do not have data are properly written.