True Unique ID

All installation and configuration problems and questions

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

True Unique ID

Postby ajax1515 » Tue Dec 15, 2015 2:14 pm

I've read in a few other posts (http://www.eflo.net/VICIDIALforum/viewt ... =3&t=27191) that unique_id may not always be "unique" which is concerning for me considering the volume of our calls and out needs for tracking.

I notice in looking at the call_log that there is also a column called called_code that has a format like this :V2151408300000004432

My question is simply this: In tracking individual dials, is the unique_id reliable in a multi server environment and if not, is the called_code an appropriate substitute?
ViciBox v.7.0.2-160325
VICIDIAL-VERSION: 2.12-550a BUILD: 160414-1013
Asterisk 11.22.0-vici
1 Database Server
MariaDB 10.1.6
2 Web Servers
Multiple Dial Servers
ajax1515
 
Posts: 70
Joined: Wed Sep 23, 2015 11:23 am

Re: True Unique ID

Postby mflorell » Tue Dec 15, 2015 4:35 pm

We do have several clients using caller_code or call_id or call_code or callerIDname(it's called different things in different places) as a uniqueid on multi-server systems, and it works pretty well.
mflorell
Site Admin
 
Posts: 18386
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: True Unique ID

Postby ajax1515 » Fri Dec 18, 2015 11:45 am

Ok, thanks, that's good to know. I'm still curious though, how could the unique id in the call_log ever not be unique, it's a MySQL primary index which means it should have to be unique, what am I missing here?
ViciBox v.7.0.2-160325
VICIDIAL-VERSION: 2.12-550a BUILD: 160414-1013
Asterisk 11.22.0-vici
1 Database Server
MariaDB 10.1.6
2 Web Servers
Multiple Dial Servers
ajax1515
 
Posts: 70
Joined: Wed Sep 23, 2015 11:23 am

Re: True Unique ID

Postby mflorell » Fri Dec 18, 2015 4:39 pm

The call_log is not used for reporting purposes at all, it's minimally used for log processing as well. uniqueid is unique per server, and it is extremely rare even on a multi-server system for it to be duplicated. It is possible in some Asterisk builds to have the servername appended to the uniqueid, which can allow the uniqueid to be truly unique even on a multi-server system.
mflorell
Site Admin
 
Posts: 18386
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: True Unique ID

Postby ajax1515 » Fri Jan 08, 2016 11:39 am

When you say multi-server systems in this particular case you are only referring to systems with more then 1 database server correct?
ViciBox v.7.0.2-160325
VICIDIAL-VERSION: 2.12-550a BUILD: 160414-1013
Asterisk 11.22.0-vici
1 Database Server
MariaDB 10.1.6
2 Web Servers
Multiple Dial Servers
ajax1515
 
Posts: 70
Joined: Wed Sep 23, 2015 11:23 am

Re: True Unique ID

Postby mflorell » Fri Jan 08, 2016 1:37 pm

No, systems with more than one Asterisk server.
mflorell
Site Admin
 
Posts: 18386
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: True Unique ID

Postby ajax1515 » Mon Jan 11, 2016 2:23 pm

I feel like I'm being a bit of a pain about this but I'm still having trouble conceptualizing how this works.

In the `asterisk` MariaDB database which is only located on the database server, the `call_log` table has as it's PRIMARY index `uniqueid` with values such as '1448488017.0'. A PRIMARY index is required by MySQL to be unique, so if what you're saying is true (obviously it is since you made it) then how does the system rectify itself when Asterisk_Server_1 creates a uniqueid that is the same as one created by Asterisk_Server_2 and in trying to INSERT it gets the Error Code: "1062. Duplicate entry 'xxxx' for key 'PRIMARY'"?

Second part of my question which dove tails from the first is: by what method (programatically) are the uniqueid's generated by the Asterisk Servers?

Thanks for your patience with me.
ViciBox v.7.0.2-160325
VICIDIAL-VERSION: 2.12-550a BUILD: 160414-1013
Asterisk 11.22.0-vici
1 Database Server
MariaDB 10.1.6
2 Web Servers
Multiple Dial Servers
ajax1515
 
Posts: 70
Joined: Wed Sep 23, 2015 11:23 am

Re: True Unique ID

Postby mflorell » Mon Jan 11, 2016 4:47 pm

The standard uniqueid within asterisk is generated in 2 parts:
1. the epoch time of the server (the number of seconds since January 01, 1970)
2. the internal Asterisk channel counter (the number of new channels created since Asterisk was started up to that point)

It is very unlikely that at the same second, the same number of channels will be used on two different asterisk servers on the same cluster. If this does happen, it would result in some logging issues, but nothing catastrophic.

On most running Vicidial systems you will see MySQL errors about duplicate key attempts on the call_log table. These errors are caused by the multiple levels of logging that exists to catch all Asterisk call events by Vicidial. On most systems, 100% of these errors can be ignored, since they only indicate that a redundant call_log entry was attempting to be inserted by one of the logging processes.
mflorell
Site Admin
 
Posts: 18386
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: True Unique ID

Postby ajax1515 » Tue Jan 12, 2016 2:26 pm

Got it, thank you for the information, it all makes sense now.
ViciBox v.7.0.2-160325
VICIDIAL-VERSION: 2.12-550a BUILD: 160414-1013
Asterisk 11.22.0-vici
1 Database Server
MariaDB 10.1.6
2 Web Servers
Multiple Dial Servers
ajax1515
 
Posts: 70
Joined: Wed Sep 23, 2015 11:23 am

Re: True Unique ID

Postby ajax1515 » Tue Feb 09, 2016 11:21 am

For those of you using newer asterisk builds, the setting that will allow you to prepend a server name to the uniqueid is found in asterisk.conf
ViciBox v.7.0.2-160325
VICIDIAL-VERSION: 2.12-550a BUILD: 160414-1013
Asterisk 11.22.0-vici
1 Database Server
MariaDB 10.1.6
2 Web Servers
Multiple Dial Servers
ajax1515
 
Posts: 70
Joined: Wed Sep 23, 2015 11:23 am

Re: True Unique ID

Postby mflorell » Tue Feb 09, 2016 4:20 pm

Just keep in mind, if you do that you will have to make every database field that contains the uniqueid big enough to handle that information.
mflorell
Site Admin
 
Posts: 18386
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: True Unique ID

Postby ajax1515 » Fri Feb 12, 2016 10:18 am

Right, I had not considered that, I'm simply prepending the server number, so it's only adding 2 characters, the number, and a hyphen, making the id's look something like 2-142342543.234, but if you were to add a larger prepended value such as "asterisk-dial-server-1" then that would become a serious problem, thanks for pointing that out.
ViciBox v.7.0.2-160325
VICIDIAL-VERSION: 2.12-550a BUILD: 160414-1013
Asterisk 11.22.0-vici
1 Database Server
MariaDB 10.1.6
2 Web Servers
Multiple Dial Servers
ajax1515
 
Posts: 70
Joined: Wed Sep 23, 2015 11:23 am


Return to Support

Who is online

Users browsing this forum: Google [Bot] and 59 guests