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

Getting DB Error #1064 from nightly cron?

I've been getting these emails on occasion.. can someone tell me what's going on and why?

Subject: DB Error #1064

[OPTIMIZE TABLE lock]

You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'lock' at line
1<br /> <br />
---- Backtrace ----<br />
#0 (root)/include/mysqli.php(204): osTicket->logDBError('DB Error #1064',
'[OPTIMIZE TABLE...')<br />
#1 (root)/include/class.cron.php(59): db_query('OPTIMIZE TABLE ...')<br />
#2 (root)/include/class.cron.php(107): Cron->MaybeOptimizeTables()<br />
#3 (root)/include/api.cron.php(19): Cron->run()<br />
#4 (root)/include/api.cron.php(40): CronApiController->run()<br />
#5 (root)/api/cron.php(23): LocalCronApiController::call()<br />
#6 {main}

Comments

  • Please help us to help you by reading and following the posting guidelines located in this thread: Please read before requesting assistance.  The more information you give us the better we will be able to assist you. Thank you.

    Also please check your PHP error logs and MySQL error logs to get the rest of the error.
    All I can tell you is that the MySQL query is trying to lock a table and failing with the error of "

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lock' at line 1".  So it could be that your version of MySQL doesn't support the lock command.  Your user doesn't have permission to use the lock command. Or something else entirely.  But if you can get me the MySQL query its running I can try to replicate this on my test site.
  • I'm running MySQL 5.1.73-cll-lve

    As for the command -- OPTIMIZE TABLE lock is the only thing being ran.. Looking at the source code,  lock in this case is the name of a table.  So, it's not a lock command. I'm guessing that it thinks lock is something special. So, I ran this command  OPTIMIZE TABLE `lock` to escape the table name and it works. 
  • Hello,

    I can confirm this problem. It will occur on every installation without table prefix because as Connor already mentioned lock is a table not a command and needs to be escaped.

    The problem can be fixed in class.cron line 59.
Sign In or Register to comment.