Cdr not working after restore

,

Hi, took backup from 16 and restored it to 17. cdr are not logging anymore

WARNING[1221]: res_odbc.c:529 ast_odbc_print_errors: SQL Execute returned an error: 42S02: [ma-3.1.15][10.11.11-MariaDB-0+deb12u1]Table 'asteriskcdrdb.transient_cdr' doesn't exist
[2025-03-28 20:12:25] WARNING[1221]: res_odbc.c:424 ast_odbc_prepare_and_execute: SQL Execute error -1!
[2025-03-28 20:12:25] WARNING[1221]: cdr_adaptive_odbc.c:766 odbc_log: cdr_adaptive_odbc: Insert failed on 'asteriskcdrdb:cdr'.  CDR failed: INSERT INTO cdr (calldate, clid, src, dst, dcontext, channel, lastapp, lastdata, duration, billsec, disposition, amaflags, uniqueid, did, cnum, cnam, linkedid, sequence) VALUES ({ ts '2025-03-28 20:12:16' }, '"+306944XXXXXX" <+306944XXXXXX>', '+306944XXXXXX', '99', 'ext-group', 'PJSIP/OTE-000009cd', 'Playback', 'custom/greeting_ale', 8, 8, 'ANSWERED', 3, '1743185536.4036', '+302310XXXXXX', '+306944XXXXXX', '+306944XXXXXX', '1743185536.4036', 3011)

Hi @xtrgeo
It looks like transient_cdr table doesn’t exist in asteriskcdrdb,
You can confirm by runn this command mysql -D asteriskcdrdb -e 'show tables;'

to fix this follow the below steps

  1. Goto Advanced Settings in theGUI and look for Transient CDR then set it to NO
  2. Submit the changes and press the apply config button
  3. Once done, just run fwconsole ma install restapps on cli mode then
  4. Run fwconsole r and check the transient_cdr table will be created, now test the calls

Well, new error now!!!

[2025-04-14 20:03:30] WARNING[1624054] res_odbc.c: SQL Execute returned an error: 42S22: [ma-3.1.15][10.11.11-MariaDB-0+deb12u1]Unknown column 'dst_cnam' in 'INSERT INTO'
52175[2025-04-14 20:03:30] WARNING[1624054] res_odbc.c: SQL Execute error -1!
52176[2025-04-14 20:03:30] WARNING[1624054] cdr_adaptive_odbc.c: cdr_adaptive_odbc:
asteriskcdrdb:cdr'. CDR failed: INSERT INTO cdr (calldate, clid, src, dst, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, amaflags, uniqueid, did, cnum, cnam, linkedid, sequence) VALUES ({ ts '2025-04-14 19:38:35' }, '"XXXXXXXXXX" <XXXXXXXXXX>', 'XXXXXXXXXX', '99', 'ext-group', 'PJSIP/OTE-00000453', 'PJSIP/12-00000455', 'Dial', 'PJSIP/11/sip:[email protected]:34442;x-ast-orig-host=94.69.XXX.XXX:34442&PJSIP/12/', 9, 9, 'NO ANSWER', 3, '1744648705.1771', '+302XXXXXXXX', 'XXXXXXXXXX', 'XXXXXXXXXX', '1744648705.1771', 1306)


the column dst_cnam DOES exists in the table!!!

Hi @xtrgeo
Just run below command that will fix the issue
fwconsole ma install cdr
fwconsole r

No, then issue is not fixed. Again the same error about the missing fileld an the INSERT INTO error

Try:

fwconsole ma downloadinstall core framework cdr
fwconsole r
1 Like
[2025-04-16 12:11:44] WARNING[1624054] res_odbc.c: SQL Execute returned an error: 42S22: [ma-3.1.15][10.11.11-MariaDB-0+deb12u1]Unknown column 'dst_cnam' in 'INSERT INTO'

8771[2025-04-16 12:11:44] WARNING[1624054] res_odbc.c: SQL Execute error -1!

8772[2025-04-16 12:11:44] WARNING[1624054] cdr_adaptive_odbc.c: cdr_adaptive_odbc: Insert failed on 'asteriskcdrdb:cdr'. CDR failed: INSERT INTO cdr (calldate, clid, src, dst, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, amaflags, uniqueid, did, cnum, cnam, linkedid, sequence) VALUES ...

I think the restore made a damage so large that is not fixing???

Hi @xtrgeo
Can you share output of below commands

mysql -D asteriskcdrdb -e 'desc cdr;'

and

fwconsole ma install cdr

sure,here it is

root@lalala:~# mysql -D asteriskcdrdb -e 'desc cdr;'
+---------------+--------------+------+-----+---------------------+-------+
| Field         | Type         | Null | Key | Default             | Extra |
+---------------+--------------+------+-----+---------------------+-------+
| calldate      | datetime     | NO   | MUL | 1000-01-01 00:00:00 |       |
| clid          | varchar(80)  | NO   |     |                     |       |
| src           | varchar(80)  | NO   |     |                     |       |
| dst           | varchar(80)  | NO   | MUL |                     |       |
| dcontext      | varchar(80)  | NO   |     |                     |       |
| channel       | varchar(80)  | NO   |     |                     |       |
| dstchannel    | varchar(80)  | NO   |     |                     |       |
| lastapp       | varchar(80)  | NO   |     |                     |       |
| lastdata      | varchar(80)  | NO   |     |                     |       |
| duration      | int(11)      | NO   |     | 0                   |       |
| billsec       | int(11)      | NO   |     | 0                   |       |
| disposition   | varchar(45)  | NO   |     |                     |       |
| amaflags      | int(11)      | NO   |     | 0                   |       |
| accountcode   | varchar(20)  | NO   | MUL |                     |       |
| uniqueid      | varchar(32)  | NO   | MUL |                     |       |
| userfield     | varchar(255) | NO   |     |                     |       |
| did           | varchar(50)  | NO   | MUL |                     |       |
| recordingfile | varchar(255) | NO   | MUL |                     |       |
| cnum          | varchar(80)  | NO   |     |                     |       |
| cnam          | varchar(80)  | NO   |     |                     |       |
| outbound_cnum | varchar(80)  | NO   |     |                     |       |
| outbound_cnam | varchar(80)  | NO   |     |                     |       |
| dst_cnam      | varchar(80)  | NO   |     |                     |       |
| linkedid      | varchar(32)  | NO   | MUL |                     |       |
| peeraccount   | varchar(80)  | NO   |     |                     |       |
| sequence      | int(11)      | NO   |     | 0                   |       |
+---------------+--------------+------+-----+---------------------+-------+
root@lalala:~#


root@lalala:~# fwconsole ma install cdr
Checking if field cnum is present in cdr table..OK!
Checking if field cnam is present in cdr table..OK!
Checking if field outbound_cnum is present in cdr table..OK!
Checking if field outbound_cnam is present in cdr table..OK!
Checking if field dst_cnam is present in cdr table..OK!
Checking if field linkedid is present in cdr table..OK!
Checking if field peeraccount is present in cdr table..OK!
Checking if field sequence is present in cdr table..OK!
Generating CSS...Done
Module cdr version 17.0.4.36 successfully installed
Updating Hooks...Done
Chowning directories...Done
root@lalala:~#


Hi @xtrgeo
As per above output the column ‘dst_cnam’ is present in the DB, but not sure why its failed to insert, so we might need system access to debug further.

please raise support ticket so we can connect to your system to debug further.

What happens when you try to insert it manually?

Why do you keep asking for open source issues to be pushed into a ticket? There hasn’t even been proper debugging done here.

Here’s the insert statement of fields being use in the insert, there isn’t a reference to dst_cnam in the insert statement.

INSERT INTO cdr (calldate, clid, src, dst, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, amaflags, uniqueid, did, cnum, cnam, linkedid, sequence)

@xtrgeo We need to see a full verbose log of a call that fails to insert so we can see what CDR fields are being set during the call. We really need to see more than 3 lines, we need the whole call. So log into the system via SSH, do asterisk -rvvvvvvvvvvvv and make a test call that fails to insert. Give us that output.

2 Likes

Also, where is dst_cnam ever used? I see no reference to it in any of the dialplan unless this is a field used by commercial modules. But I can’t see any open source module using this cdr field. Not even sure why it exists, I never see it populated in the CDR table.