Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

DB Error #1062 Duplicate entry


Today I have received 3 emails with the subject "DB Error #1062" and the body:
[INSERT INTO `ost_session` SET `session_id` = 'gqk8i410k4fitvtt8ol0s00n86', `session_data` = 'csrf|a:2:{s:5:\"token\";s:40:\"26724f861fc5191944318d599a6f29d7ec1bdb89\";s:4:\"time\";i:1520387480;}', `session_expire` = NOW() + INTERVAL 86400 SECOND, `user_ip` = '', `user_agent` = 'Mozilla/5.0 (compatible; Googlebot/2.1; +']

Duplicate entry 'gqk8i410k4fitvtt8ol0s00n86' for key 'PRIMARY'<br />
<br />
---- Backtrace ----<br />
#0 (root)/include/mysqli.php(204): osTicket->logDBError('DB Error #1062', '[INSERT INTO `o...')<br />
#1 (root)/include/class.orm.php(3133): db_query('INSERT INTO `os...', true, true)<br />
#2 (root)/include/class.orm.php(597): MySqlExecutor->execute()<br />
#3 (root)/include/class.ostsession.php(216): VerySimpleModel->save()<br />
#4 (root)/include/class.ostsession.php(158): DbSessionBackend->update('gqk8i410k4fitvt...', 'csrf|a:2:{s:5:"...')<br />
#5 [internal function]: SessionBackend->write('gqk8i410k4fitvt...', 'csrf|a:2:{s:5:"...')<br />
#6 [internal function]: session_write_close()<br />
#7 {main}
I have updated to osTicket 1.10.1 a few days ago. And I was not receiving this error before.

What could be the problem?


  • Well it says that its trying to insert a record to the session table, and that the session already exists.
    My guess is that perhaps you ahve a bunch of old sessions that haven't been cleaned up in a long time for some reason.  You could try dropping the content of the session table and see if it occurs again.
  • Thanks. I have just done it. I will see if I still get the errors.

    I have also got this error:
    [INSERT INTO `ost_attachment` SET `file_id` = 4187, `type` = 'D', `object_id` = 40018]

    Duplicate entry '40018-4187-D' for key 'file-type'<br />
    <br />
    ---- Καταγραφή Σφάλματος (Backtrace) ----<br />
    #0 (αρχικό σημείο)/include/mysqli.php(204): osTicket->logDBError('DB Error #1062', '[INSERT INTO `o...')<br />
    #1 (αρχικό σημείο)/include/class.orm.php(3133): db_query('INSERT INTO `os...', true, true)<br />
    #2 (αρχικό σημείο)/include/class.orm.php(597): MySqlExecutor->execute()<br />
    #3 (αρχικό σημείο)/include/class.attachment.php(161): VerySimpleModel->save()<br />
    #4 (αρχικό σημείο)/include/ajax.draft.php(101): GenericAttachments->upload(Array)<br />
    #5 (αρχικό σημείο)/include/ajax.draft.php(300): DraftAjaxAPI->_uploadInlineImage(Object(Draft))<br />
    #6 (αρχικό σημείο)/include/class.dispatcher.php(145): DraftAjaxAPI->uploadInlineImage('40018')<br />
    #7 (αρχικό σημείο)/include/class.dispatcher.php(38): UrlMatcher->dispatch('40018/attach', Array)<br />
    #8 (αρχικό σημείο)/include/class.dispatcher.php(120): Dispatcher->resolve('40018/attach', Array)<br />
    #9 (αρχικό σημείο)/include/class.dispatcher.php(38): UrlMatcher->dispatch('/draft/40018/at...', NULL)<br />
    #10 (αρχικό σημείο)/scp/ajax.php(262): Dispatcher->resolve('/draft/40018/at...')<br />
    #11 {main}
  • edited March 8
    Hi, i just got many times the error "Insert into 'ost_attachment' ". I spoke to the agent and he said that he was trying to copy/paste a table from excel to the message.

  • @Kerfred With out knowing what the agent (or email?) was doing that caused the error it would be hard to diagnose, but it says it tried to create a record for an attachment, and an attachment with that key already exists.
  • This happens to us many times. The error occurs when writing a reply to a client in the WYSIWYG editor and you paste in an image. When the draft of your reply is saved the image attachment is created in the db. If you carry on writing your reply long enough for a second or subsequent draft save to occur, the attachment is already in the db  and the save attempt fails with that duplicate message.

    It is not a serious problem as the attachment seems to be there when the reply is actually posted, it is more of an annoyance getting these emails in regard to the problem.
  • We have got the same problem but the image is not even saved. All we see is small rotating circle where the image should be. When we save, the image is gone.
Sign In or Register to comment.