• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

MySQL query error [1615]: Prepared statement needs to be re-prepared (Recurring)

invictus

Active member
#1
I got this error in my server log twice after upgrading from 1.5 to XF2. I cleared them and kept working, everything seems to be fine on the forum.

Now I am seeing the same error again. Not sure how to read it or what it means.

Server error log
Code:
XF\Db\Exception: MySQL query error [1615]: Prepared statement needs to be re-prepared src/XF/Db/AbstractStatement.php:183
Generated by: Unknown account Oct 18, 2017 at 12:30 AM
Stack trace
Code:
#0 src/XF/Db/Mysqli/Statement.php(66): XF\Db\AbstractStatement->getException('MySQL query err...', 1615)
#1 src/XF/Db/AbstractAdapter.php(67): XF\Db\Mysqli\Statement->execute()
#2 src/XF/Mvc/Entity/Finder.php(1105): XF\Db\AbstractAdapter->query('\r\n\t\t\tSELECT `xf...')
#3 src/XF/Pub/Controller/Forum.php(983): XF\Mvc\Entity\Finder->fetchOne()
#4 src/XF/Pub/Controller/Forum.php(190): XF\Pub\Controller\Forum->assertViewableForum('7', Array)
#5 src/XF/Mvc/Dispatcher.php(249): XF\Pub\Controller\Forum->actionForum(Object(XF\Mvc\ParameterBag))
#6 src/XF/Mvc/Dispatcher.php(88): XF\Mvc\Dispatcher->dispatchClass('XF:Forum', 'Forum', 'html', Object(XF\Mvc\ParameterBag), 'forums', Object(XF\Pub\Controller\Forum), Object(XF\Mvc\Reply\Reroute))
#7 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#8 src/XF/App.php(1831): XF\Mvc\Dispatcher->run()
#9 src/XF.php(328): XF\App->run()
#10 index.php(13): XF::runApp('XF\\Pub\\App')
#11 {main}
Request state
Code:
array(4) {
  ["url"] => string(40) "/forum/forums/general-board.7/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 

Chris D

XenForo developer
Staff member
#2
Generally this is a server side issue rather than a code issue.

It was a larger problem in some older MySQL versions but I when it is seen now changing table_definition_cache is the solution. This can be changed in my.cnf or by your host.
 

invictus

Active member
#3
Thanks @Chris D - I'm running MariaDB 10.1, not exactly an old MySQL version.

table_definition_cache was set to the default of 400. I increased it to 1200, do you think that is sufficient?
 

invictus

Active member
#5
Still getting these with table_definition_cache=1200, do I need to increase the value again or could this be another issue?

Server error log

Code:
XF\Db\Exception: MySQL query error [1615]: Prepared statement needs to be re-prepared src/XF/Db/AbstractStatement.php:183
Generated by: Unknown account Oct 18, 2017 at 4:30 PM
Stack trace
Code:
#0 src/XF/Db/Mysqli/Statement.php(66): XF\Db\AbstractStatement->getException('MySQL query err...', 1615)
#1 src/XF/Db/AbstractAdapter.php(67): XF\Db\Mysqli\Statement->execute()
#2 src/XF/Mvc/Entity/Finder.php(1138): XF\Db\AbstractAdapter->query('\r\n\t\t\tSELECT `xf...')
#3 src/XF/Pub/Controller/Thread.php(36): XF\Mvc\Entity\Finder->fetch()
#4 src/XF/Mvc/Dispatcher.php(249): XF\Pub\Controller\Thread->actionIndex(Object(XF\Mvc\ParameterBag))
#5 src/XF/Mvc/Dispatcher.php(88): XF\Mvc\Dispatcher->dispatchClass('XF:Thread', 'Index', 'html', Object(XF\Mvc\ParameterBag), 'forums', Object(DBTech\PreviewLastPost\XF\Pub\Controller\Thread), NULL)
#6 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#7 src/XF/App.php(1831): XF\Mvc\Dispatcher->run()
#8 src/XF.php(328): XF\App->run()
#9 index.php(13): XF::runApp('XF\\Pub\\App')
#10 {main}
Request state
Code:
array(4) {
  ["url"] => string(52) "/forum/threads/enhancing-old-35mm-slide-scans.60742/"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 

Chris D

XenForo developer
Staff member
#6
It could be another issue. Unfortunately there's an on-going debacle where people who have experienced this issue feel that it is a bug and they report it as such but it has been claimed it isn't a bug. It was definitely more prevalent in older versions IIRC, though clearly people are still experiencing it. Worth a read:

https://bugs.mysql.com/bug.php?id=42041

There might be some other solutions mentioned in there.

Ultimately if possible it might be something to raise with your hosting provider.