[asterisk-users] Is uniqueid/sequence a safe CDR table primary key ?
Matthew Jordan
mjordan at digium.com
Mon Jun 3 11:58:19 CDT 2013
On 06/03/2013 11:20 AM, Olivier wrote:
> Hi,
>
> When dealing with CDR SQL tables, I always added an auto-incremented
> cdr_id key as a primary key, just in case provided uniqueid key went wrong.
>
> Now I'm facing a situation where I need to insert into a database's
> table and from the dialplan, a reference to the CDR record which is
> currently processed.
>
> So my questions are:
>
> 1. Can uniqueid/sequence (or uniqueid/sequence/calldate) bundle be
> safely used as CDR's table primary key (ie I cannot have any
> uniqueid/sequence combination from one CDR record to match a past
> uniqueid/sequence combination) ?
Possibly. Things to keep in mind:
* You can run into uniqueid collisions across multiple systems if you do
not specify a system name in asterisk.conf or do not specify a unique
system name in asterisk.conf.
* You can run into uniqueid collisions if your system clock goes
backwards for any reason (the uniqueid for a channel happens to use a
timestamp for its uniqueness)
Whether or not this is unique enough will be completely dependent on
your overall system configuration.
In general, the recommended combination that *should* uniquely specify a
CDR (when configured correctly) is linkedid (which should be enabled and
added to your schema), uniqueid, and sequence number, with the asterisk
system name specified.
--
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org
More information about the asterisk-users
mailing list