Error on slave database: Duplicate entry

Discussions about development of VICIDIAL and astGUIclient

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

Error on slave database: Duplicate entry

Postby DomeDan » Tue Nov 13, 2012 5:43 am

Have you thought about this issue?:
http://www.vicidial.org/VICIDIALmantis/view.php?id=619
I would change to the master database and then back to slave to prevent this,
or is there any other way you would do it?
if not then I can write a patch to solve this.
Vicidial Partner. Region: Sweden/Norway.
Does Vicidial installation, configuration, customization, add-ons, CRM implementation, support, upgrading, network-related, pentesting etc. Remote and onsite assistance.
Email: domedan (at) gmail.com
DomeDan
 
Posts: 1226
Joined: Tue Jan 04, 2011 9:17 am
Location: Sweden

Re: Error on slave database: Duplicate entry

Postby mflorell » Tue Nov 13, 2012 7:12 am

Good catch!

We are planning on adding admin logging to all reports, so this is something we are going to have to address on all report scripts in the near future.
mflorell
Site Admin
 
Posts: 18338
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: Error on slave database: Duplicate entry

Postby williamconley » Tue Nov 13, 2012 6:00 pm

store a UUID function in the database and use it to generate the key for anything that will happen in the admin logs. need a diff?
Vicidial Installation and Repair, plus Hosting and Colocation
Newest Product: Vicidial Agent Only Beep - Beta
http://www.PoundTeam.com # 352-269-0000 # +44(203) 769-2294
williamconley
 
Posts: 20019
Joined: Wed Oct 31, 2007 4:17 pm
Location: Davenport, FL (By Disney!)

Re: Error on slave database: Duplicate entry

Postby DomeDan » Fri Aug 29, 2014 6:33 am

Got an other report with this issue: "Search Leads Logs"

same problem as in issue http://www.vicidial.org/VICIDIALmantis/view.php?id=619

* setup slave database
* use slave database for reports
* run a "Search Leads Logs" that uses slave + some other report that uses master later
then it uses the slave database for every query in admin_search_lead.php including "INSERT INTO vicidial_admin_log ...."
and when the master database does an other insert into vicidial_admin_log and the replication process copy it over to the slave then the slave complains when the private key id already exists:
Error 'Duplicate entry '23107' for key 'PRIMARY'' on query. Default database: 'asterisk'. Query: 'INSERT INTO vicidial_admin_log set event_date='2014-08-29 10:06:42', user='1234', ip_address='1.1.1.1', event_section='LEADS', event_type='SEARCH', record_id='616387', event_code='ADMIN SEARCH LEAD', event_sql="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner from vicidial_list where first_name=\\'eddie\\' and last_name=\\'meduza\\' order by last_local_call_time desc limit 1000|", event_notes='''

and the slave stops and all reports using slave seams to get stuck in time
Vicidial Partner. Region: Sweden/Norway.
Does Vicidial installation, configuration, customization, add-ons, CRM implementation, support, upgrading, network-related, pentesting etc. Remote and onsite assistance.
Email: domedan (at) gmail.com
DomeDan
 
Posts: 1226
Joined: Tue Jan 04, 2011 9:17 am
Location: Sweden

Re: Error on slave database: Duplicate entry

Postby williamconley » Fri Aug 29, 2014 2:20 pm

Temporary solution: Disable logging of admin searches if you're linked to the slave db.

Or force placement of that log entry into the master even though you're connected to the slave.
Vicidial Installation and Repair, plus Hosting and Colocation
Newest Product: Vicidial Agent Only Beep - Beta
http://www.PoundTeam.com # 352-269-0000 # +44(203) 769-2294
williamconley
 
Posts: 20019
Joined: Wed Oct 31, 2007 4:17 pm
Location: Davenport, FL (By Disney!)

Re: Error on slave database: Duplicate entry

Postby DomeDan » Thu Sep 18, 2014 7:11 am

Just change the system setting to not use slave database for reports is the first thing to do. :wink:

I've made a patch to fix the issue in admin_search_lead.php http://www.vicidial.org/VICIDIALmantis/view.php?id=790
what I did was to add code to change to master before doing a INSERT or UPDATE like it was done in lead_report_export.php http://www.vicidial.org/VICIDIALmantis/view.php?id=619
Vicidial Partner. Region: Sweden/Norway.
Does Vicidial installation, configuration, customization, add-ons, CRM implementation, support, upgrading, network-related, pentesting etc. Remote and onsite assistance.
Email: domedan (at) gmail.com
DomeDan
 
Posts: 1226
Joined: Tue Jan 04, 2011 9:17 am
Location: Sweden

Re: Error on slave database: Duplicate entry

Postby geoff3dmg » Thu Sep 18, 2014 8:16 am

Thanks for the patch Domdan, I've had this happen occasionally here. I'd like to point out that it's also a good idea to set slave database servers to read only.

https://mariadb.com/blog/looking-slave- ... kip-errors
Vicibox 5.03 from .iso | VERSION: 2.10-451a BUILD: 140902-0816 | Asterisk 1.8.28.2-vici | Multi-Server | Amfeltec H/W Timing Cards | No Extra Software After Installation | Dell PowerEdge 1850 | Pentium 4 'Prescott' Xenon Quad @ 3.40GHz
geoff3dmg
 
Posts: 403
Joined: Tue Jan 29, 2013 4:35 am
Location: Lancashire, UK

Re: Error on slave database: Duplicate entry

Postby DomeDan » Thu Sep 18, 2014 8:24 am

oh, didnt know about the read only option, it makes perfectly sense to have that option.
though it had to be read/write to be able to run the replication.
Thanks geoff3dmg! :D
Vicidial Partner. Region: Sweden/Norway.
Does Vicidial installation, configuration, customization, add-ons, CRM implementation, support, upgrading, network-related, pentesting etc. Remote and onsite assistance.
Email: domedan (at) gmail.com
DomeDan
 
Posts: 1226
Joined: Tue Jan 04, 2011 9:17 am
Location: Sweden


Return to Development

Who is online

Users browsing this forum: No registered users and 36 guests