Hi, every time a ticket is created i get DB Error #1062 with alert email:

[INSERT INTO `LVti_thread_referral` SET `thread_id` = 158,  `object_id` = 12,  `object_type` = 'D',  `created` = NOW()] Duplicate entry '12-D-158' for key 'ref'

 ---- Backtrace ----
 #0 (root)/include/mysqli.php(199): osTicket->logDBError('DB Error #1062',  '[INSERT INTO `L...')
 #1 (root)/include/class.orm.php(3455): db_query('INSERT INTO `LV...',  true,  true)
 #2 (root)/include/class.orm.php(658): MySqlExecutor->execute()
 #3 (root)/include/class.thread.php(1824): VerySimpleModel->save()
 #4 (root)/include/class.thread.php(362): ThreadReferral::create(Array)
 #5 (root)/include/class.ticket.php(2602): Thread->refer(Object(Dept))
 #6 (root)/include/class.thread.php(570): Ticket->systemReferral(Array)
 #7 (root)/include/class.thread.php(844): Thread->postEmail(Array,  Object(ThreadEntry))
 #8 (root)/include/class.mailfetch.php(861): ThreadEntry->postEmail(Array)
 #9 (root)/include/class.mailfetch.php(933): MailFetcher->createTicket(1)
 #10 (root)/include/class.mailfetch.php(1013): MailFetcher->fetchEmails()
 #11 (root)/include/class.cron.php(25): MailFetcher::run()
 #12 (root)/include/class.cron.php(110): Cron::MailFetcher()
 #13 (root)/include/api.cron.php(19): Cron::run()
 #14 (root)/include/api.cron.php(40): CronApiController->run()
 #15 (root)/api/cron.php(23): LocalCronApiController::call()
 #16 {main}

How i can solve? I use the last stable release
v1.12.3 (bcf1a6f)
Web Server Software Apache
Versione MySQL 5.6.45
Versione PHP 7.3.7

Maybe this because i tried to add an image at the start of the ticket with the logo and this after a while doesn't work anymore so i was forced to delete the code line with the image from the text editor.

But now how i can stop this issue that send an alert email every time and do log on the registry?


I opened phpmyadmin than searched for ref and found LVti_thread_referral
here i have two lines - what i have to do?

Seems on every new ticket the object id is keept same so error comes.

@PeopleInside

Thank you for your reply, what i can do for "figure out which one is being duplicated"?
Seems the issue is with the object is = 12 can i remove this object? what is? Where i can remove? how to do?
(image)
I don't know how i can fix this.

It is the combination of all the values that is duplicated since thread_id, object_id, and object_type are not forced to be unique independently rather altogether as a key ref. It appears you already have a Thread with an ID of 158 referred to the Department (D) with an ID of 12. What are the exact steps you are taking to cause this error?

I see this:
(image)
I can just replace on of two from 12 to 13 ?

This screenshot has nothing to do with your original error (Duplicate entry '12-D-158' for key 'ref'). If you have another error regarding attachments you can create a separate post with full details on how to replicate the issue, your system info, etc.

Cheers.

    KevinTheJedi umh in the database i have to search for 12-D-158?
    I found this only in the error logs.
    I don't know how to find the duplicate in the database and remove, i don't know the steps as usually i do not navigaste into database. Is OsTicket that caused this duplicate error :S

    What steps i have to follow?

    Logs say:

    
    (49, 'Error', 'DB Error #1062', '[INSERT INTO `LVti_thread_referral` SET `thread_id` = 157, `object_id` = 12, `object_type` = \'D\', `created` = NOW()] Duplicate entry \'12-D-157\' for key \'ref\'<br /><br /> ---- Backtrace ----<br /> #0 (root)/include/mysqli.php(199): osTicket-&gt;logDBError(\'DB Error #1062\', \'[INSERT INTO `L...\')<br /> #1 (root)/include/class.orm.php(3455): db_query(\'INSERT INTO `LV...\', true, true)<br /> #2 (root)/include/class.orm.php(658): MySqlExecutor-&gt;execute()<br /> #3 (root)/include/class.thread.php(1824): VerySimpleModel-&gt;save()<br /> #4 (root)/include/class.thread.php(362): ThreadReferral::create(Array)<br /> #5 (root)/include/class.ticket.php(2602): Thread-&gt;refer(Object(Dept))<br /> #6 (root)/include/class.thread.php(570): Ticket-&gt;systemReferral(Array)<br /> #7 (root)/include/class.thread.php(844): Thread-&gt;postEmail(Array, Object(ThreadEntry))<br /> #8 (root)/include/class.mailfetch.php(861): ThreadEntry-&gt;postEmail(Array)<br /> #9 (root)/include/class.mailfetch.php(933): MailFetcher-&gt;createTicket(1)<br /> #10 (root)/include/class.mailfetch.php(1013): MailFetcher-&gt;fetchEmails()<br /> #11 (root)/include/class.cron.php(25): MailFetcher::run()<br /> #12 (root)/scp/autocron.php(69): Cron::MailFetcher()<br /> #13 {main}', '', '***', '2019-10-25 18:18:23', '2019-10-25 18:18:23'),
    (50, 'Error', 'DB Error #1062', '[INSERT INTO `LVti_thread_referral` SET `thread_id` = 158, `object_id` = 12, `object_type` = \'D\', `created` = NOW()] Duplicate entry \'12-D-158\' for key \'ref\'<br />

    @PeopleInside

    • Go to ost_thread_referral table
    • thread_id = 158 AND object_id = 12 AND object_type = 'D'
    • Copy the record just in case
    • Delete the record

      KevinTheJedi I deleted the two lines. thread is 157 and 158
      I'm not sure this will solve in the future this error but will see. Thanks.

      Write a Reply...