Summary:ASTERISK-12170: UNIQUE ID field length too small
Reporter:rayjay (rayjay)Labels:
Date Opened:2008-06-10 23:45:58Date Closed:2008-06-11 12:38:55
Versions:Frequency of
Description:I have noticed that the uniqueid field is too small when you define a 'systemname' on your asterisk server.  In my case I define the systemname as the IP address of the server, so this could be up to 15 characters long e.g.  The following code in main/channel.c then creates the uniqueid string for CDR etc.

ast_string_field_build(tmp, uniqueid, "%s-%li.%d", ast_config_AST_SYSTEM_NAME,
 (long) time(NULL), ast_atomic_fetchadd_int(&uniqueint, 1));

The problem is that uniqueid is only a char[32] in length.  So, here is an example uniqueid from a call:

With the hyphen, epoch timestamp, the dot and then the ast_atomic integer - the total length here is 33 characters so when I view my CDR the uniqueid is truncated e.g. - and suddenly my uniqueid is no longer unique anymore?

I have been having issues when the final integer passes 99999 - which because of Asterisk's stability :) - happens after just a few days and my CDR starts to show duplicate uniqueid's :(

I think given the fact that the systemname can be up to 20 characters and to allow for a million calls then we should make the uniqueid field at least a 40 character string?
Comments:By: Tilghman Lesher (tilghman) 2008-06-11 11:57:43

I agree with you that that CDR field needs to be longer, but this would break binary compatibility if we changed the length of that field in 1.4.  I am therefore only going to make this change in trunk.

And actually 150, since 127 + "-" + 10 + "." + 10 + NULL = 150.  Systemname does not necessarily need to be an IP address.

As a workaround in 1.4, you may need to consider shortening your systemname to just the last 2 octets of your IP address.

By: Digium Subversion (svnbot) 2008-06-11 12:37:58

Repository: asterisk
Revision: 121855

U   trunk/UPGRADE.txt
U   trunk/contrib/scripts/realtime_pgsql.sql
U   trunk/include/asterisk/cdr.h

r121855 | tilghman | 2008-06-11 12:37:55 -0500 (Wed, 11 Jun 2008) | 3 lines

Expand CDR uniqueid field to 150 chars, to account for maximum systemname.
(Closes issue ASTERISK-12170)



By: Digium Subversion (svnbot) 2008-06-11 12:38:55

Repository: asterisk
Revision: 121856

_U  branches/1.6.0/
U   branches/1.6.0/UPGRADE.txt
U   branches/1.6.0/contrib/scripts/realtime_pgsql.sql
U   branches/1.6.0/include/asterisk/cdr.h

r121856 | tilghman | 2008-06-11 12:38:54 -0500 (Wed, 11 Jun 2008) | 11 lines

Merged revisions 121855 via svnmerge from

r121855 | tilghman | 2008-06-11 12:44:39 -0500 (Wed, 11 Jun 2008) | 3 lines

Expand CDR uniqueid field to 150 chars, to account for maximum systemname.
(Closes issue ASTERISK-12170)