Message=Duplicate entry '4657089' for key 'PRIMARY'

For complex topics that regular users would not be interested in. For power users and database administrators.
Post Reply
User avatar
wjstarck
Posts: 881
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Message=Duplicate entry '4657089' for key 'PRIMARY'

Post by wjstarck » Tue Jun 22, 2021 9:35 am

Hello-

I'm trying to track down a bug for a customer that necessitated downloading their db. So, their db is running on OD 21.1.x in a production environment. But when I try to run OD on my development machine, I get:

MySql.Data.MySqlClient.MySqlException
HResult=0x80004005
Message=Duplicate entry '4657089' for key 'PRIMARY'
Source=OpenDentBusiness
StackTrace:
at OpenDentBusiness.DataCore.ExecuteQueryFunc[T](Func`1 f) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDentBusiness\Db\DataCore.cs:line 82
at OpenDentBusiness.DataCore.NonQ(String command, Boolean getInsertID, String columnNamePK, String tableName, OdSqlParameter[] parameters) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDentBusiness\Db\DataCore.cs:line 42
at OpenDentBusiness.Db.NonQ(String command, Boolean getInsertID, String columnNamePK, String tableName, OdSqlParameter[] parameters) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDentBusiness\Db\Db.cs:line 325
at OpenDentBusiness.Crud.SecurityLogCrud.Insert(SecurityLog securityLog, Boolean useExistingPK) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDentBusiness\Crud\SecurityLogCrud.cs:line 142
at OpenDentBusiness.Crud.SecurityLogCrud.Insert(SecurityLog securityLog) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDentBusiness\Crud\SecurityLogCrud.cs:line 106
at OpenDentBusiness.SecurityLogs.Insert(SecurityLog log) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDentBusiness\Data Interface\SecurityLogs.cs:line 143
at OpenDentBusiness.SecurityLogs.MakeLogEntry(SecurityLog secLog) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDentBusiness\Data Interface\SecurityLogs.cs:line 272
at OpenDentBusiness.SecurityLogs.MakeLogEntry(Permissions permType, Int64 patNum, String logText, Int64 fKey, LogSources logSource, Int64 defNum, Int64 defNumError, DateTime DateTPrevious) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDentBusiness\Data Interface\SecurityLogs.cs:line 249
at OpenDentBusiness.SecurityLogs.MakeLogEntry(Permissions permType, Int64 patNum, String logText, Int64 fKey, LogSources logSource, DateTime DateTPrevious) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDentBusiness\Data Interface\SecurityLogs.cs:line 240
at OpenDentBusiness.SecurityLogs.MakeLogEntry(Permissions permType, Int64 patNum, String logText) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDentBusiness\Data Interface\SecurityLogs.cs:line 218
at OpenDental.FormLogOn.butOK_Click(Object sender, EventArgs e) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDental\Forms\FormLogOn.cs:line 171
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at OpenDental.UI.Button.OnClick(EventArgs ea) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDental\UI\Button.cs:line 177
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at OpenDental.FormOpenDental.ShowLogOn() in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDental\Main Modules\FormOpenDental.cs:line 7002
at OpenDental.FormOpenDental.LogOnOpenDentalUser(String odUser, String odPassword, String domainUserFromCmd) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDental\Main Modules\FormOpenDental.cs:line 6956
at OpenDental.FormOpenDental.FormOpenDentalShown() in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDental\Main Modules\FormOpenDental.cs:line 657
at OpenDental.FormOpenDental.FormOpenDental_Shown(Object sender, EventArgs e) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDental\Main Modules\FormOpenDental.cs:line 364
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnShown(EventArgs e)
at System.Windows.Forms.Form.CallShownEvent()
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at OpenDental.FormODBase.WndProc(Message& m) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDental\UI\BordersDpi\FormODBase.cs:line 1193
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at OpenDental.ProgramEntry.Main(String[] args) in C:\Users\William\Desktop\ODVersions\opendental21.1\opendental21.1\OpenDental\Main Modules\ProgramEntry.cs:line 114

This exception was originally thrown at this call stack:
OpenDentBusiness.DataCore.ExecuteQueryFunc<T>(System.Func<T>) in DataCore.cs
OpenDentBusiness.DataCore.NonQ(string, bool, string, string, OpenDentBusiness.OdSqlParameter[]) in DataCore.cs
OpenDentBusiness.Db.NonQ(string, bool, string, string, OpenDentBusiness.OdSqlParameter[]) in Db.cs
OpenDentBusiness.Crud.SecurityLogCrud.Insert(OpenDentBusiness.SecurityLog, bool) in SecurityLogCrud.cs
OpenDentBusiness.Crud.SecurityLogCrud.Insert(OpenDentBusiness.SecurityLog) in SecurityLogCrud.cs
OpenDentBusiness.SecurityLogs.Insert(OpenDentBusiness.SecurityLog) in SecurityLogs.cs
OpenDentBusiness.SecurityLogs.MakeLogEntry(OpenDentBusiness.SecurityLog) in SecurityLogs.cs
OpenDentBusiness.SecurityLogs.MakeLogEntry(OpenDentBusiness.Permissions, long, string, long, OpenDentBusiness.LogSources, long, long, System.DateTime) in SecurityLogs.cs
OpenDentBusiness.SecurityLogs.MakeLogEntry(OpenDentBusiness.Permissions, long, string, long, OpenDentBusiness.LogSources, System.DateTime) in SecurityLogs.cs
OpenDentBusiness.SecurityLogs.MakeLogEntry(OpenDentBusiness.Permissions, long, string) in SecurityLogs.cs
...
[Call Stack Truncated]


Why am I getting this error? FYI, I ran database maintenance on their db before copying it. Not sure if it matters, but I am running MySQL 5.6 on my machine, but the office is running 5.5
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
TX, USA

User avatar
wjstarck
Posts: 881
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Message=Duplicate entry '4657089' for key 'PRIMARY'

Post by wjstarck » Tue Jun 22, 2021 10:11 am

Searched forums and it looks like this might be caused by a crashed or corrupted table. Looks like the fix is to run optimize tables from the DB maintenance tool. Will post again if that doesn't fix it.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
TX, USA

Tom Zaccaria
Posts: 317
Joined: Mon Feb 25, 2008 4:09 am

Re: Message=Duplicate entry '4657089' for key 'PRIMARY'

Post by Tom Zaccaria » Wed Jun 23, 2021 7:33 am

That should work. I have found that this happens, error message, whenever I try to backup hot. That is when anybody is using OD. All users have to be signed out .Been happening for a long time. OD central hasn't been able to find a fix.
BTW I use xcopy for backups.

drtmz

User avatar
wjstarck
Posts: 881
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Message=Duplicate entry '4657089' for key 'PRIMARY'

Post by wjstarck » Wed Jun 23, 2021 8:05 am

Optimize tables nuked all the gremlins. Good now
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
TX, USA

Post Reply