Won't fix MySQL query error [1062]: Duplicate entry

Nirjonadda

Well-known member
Affected version
2.1.5
Does not know this Server error log from Xenforo bug?

Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry 'thread-67518' for key 'content_type_content_id' src/XF/Db/AbstractStatement.php:228

Generated by: Black Knight Dec 1, 2019 at 8:01 PM

Stack trace

INSERT  INTO `xf_poll` (`content_type`, `content_id`, `question`, `max_votes`, `change_vote`, `public_votes`, `view_results_unvoted`, `poll_id`, `responses`, `voter_count`, `close_date`, `hide_results`, `until_close`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException('MySQL query err...', 1062, '23000')
#1 src/XF/Db/Mysqli/Statement.php(77): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1062, '23000')
#2 src/XF/Db/AbstractAdapter.php(94): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(218): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1452): XF\Db\AbstractAdapter->insert('xf_poll', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1184): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Service/Poll/Creator.php(125): XF\Mvc\Entity\Entity->save()
#7 src/XF/Service/ValidateAndSavableTrait.php(40): XF\Service\Poll\Creator->_save()
#8 src/XF/ControllerPlugin/Poll.php(29): XF\Service\Poll\Creator->save()
#9 src/addons/SV/HidePollResults/XF/ControllerPlugin/Poll.php(14): XF\ControllerPlugin\Poll->actionCreate('thread', Object(SV\ElasticSearchEssentials\XF\Entity\Thread), Array)
#10 src/XF/Pub/Controller/Thread.php(800): SV\HidePollResults\XF\ControllerPlugin\Poll->actionCreate('thread', Object(SV\ElasticSearchEssentials\XF\Entity\Thread), Array)
#11 src/XF/Mvc/Dispatcher.php(350): XF\Pub\Controller\Thread->actionPollCreate(Object(XF\Mvc\ParameterBag))
#12 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Thread', 'PollCreate', Object(XF\Mvc\RouteMatch), Object(SV\ElasticSearchEssentials\XF\Pub\Controller\Thread), NULL)
#13 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(SV\ElasticSearchEssentials\XF\Pub\Controller\Thread), NULL)
#14 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#15 src/XF/App.php(2184): XF\Mvc\Dispatcher->run()
#16 src/XF.php(391): XF\App->run()
#17 index.php(20): XF::runApp('XF\\Pub\\App')
#18 {main}

Request state

array(4) {
  ["url"] => string(79) "/threads/other.67518/poll/create"
  ["referrer"] => string(90) "/threads/other.67518/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(5) {
    ["poll"] => array(5) {
      ["question"] => string(15) "Like The Thread"
      ["new_responses"] => array(5) {
        [0] => string(3) "Yes"
        [1] => string(13) "Not Very Much"
        [2] => string(2) "No"
        [3] => string(25) "Don't Like Those Hot Olds"
        [4] => string(0) ""
      }
      ["max_votes_type"] => string(6) "single"
      ["change_vote"] => string(1) "1"
      ["view_results_unvoted"] => string(1) "1"
    }
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(68) "/threads/other.67518/"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
 
One more Server error log from Duplicate entry 'content_type_content_id'

Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry 'post-1080838' for key 'content_type_content_id' src/XF/Db/AbstractStatement.php:228

Generated by: Black Knight Dec 7, 2019 at 1:07 AM

Stack trace

INSERT  INTO `xf_report` (`content_type`, `content_id`, `content_user_id`, `content_info`, `first_report_date`, `last_modified_date`, `last_modified_user_id`, `last_modified_username`, `report_id`, `report_state`, `assigned_user_id`, `comment_count`, `report_count`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException('MySQL query err...', 1062, '23000')
#1 src/XF/Db/Mysqli/Statement.php(77): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1062, '23000')
#2 src/XF/Db/AbstractAdapter.php(94): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(218): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1452): XF\Db\AbstractAdapter->insert('xf_report', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1184): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Service/Report/Creator.php(199): XF\Mvc\Entity\Entity->save(true, false)
#7 src/addons/DBTech/Credits/XF/Service/Report/Creator.php(40): XF\Service\Report\Creator->_save()
#8 src/XF/Service/ValidateAndSavableTrait.php(40): DBTech\Credits\XF\Service\Report\Creator->_save()
#9 src/XF/ControllerPlugin/Report.php(48): XF\Service\Report\Creator->save()
#10 src/XF/Pub/Controller/Post.php(327): XF\ControllerPlugin\Report->actionReport('post', Object(SV\BookmarkEssentials\XF\Entity\Post), '/posts/1080838/...', '/posts/1080838/')
#11 src/XF/Mvc/Dispatcher.php(350): XF\Pub\Controller\Post->actionReport(Object(XF\Mvc\ParameterBag))
#12 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Post', 'Report', Object(XF\Mvc\RouteMatch), Object(TickTackk\ChangeContentOwner\XF\Pub\Controller\Post), NULL)
#13 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(TickTackk\ChangeContentOwner\XF\Pub\Controller\Post), NULL)
#14 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#15 src/XF/App.php(2184): XF\Mvc\Dispatcher->run()
#16 src/XF.php(391): XF\App->run()
#17 index.php(20): XF::runApp('XF\\Pub\\App')
#18 {main}

Request state

array(4) {
  ["url"] => string(21) "/posts/1080838/report"
  ["referrer"] => string(37) "/threads/67770/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(5) {
    ["message"] => string(23) "correct the thread name"
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(15) "/threads/67770/"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
 
These are both race conditions. These can happen and if they're infrequent, they can be ignored (as a refresh would resolve it). If they happen more commonly, that might be something to investigate. However, they can also be exacerbated by an overloaded server and be part of a set of cascading failures.

Race conditions can potentially be resolved, though the best approach to that has to be considered on a case by case basis. In both of these cases, they should be exceedingly rare (this is the only report on these tables), so at this time, we're not going to make any changes to these areas. If they continue happening, let us know and we may investigate whether anything can be done.
 
Back
Top Bottom