Menu

#682 MySQL cron database locks not being released

v2.1
open
nobody
Database (56)
5
2007-04-10
2007-04-10
No

When trying to investigate a problem with MM not processing mail when using the MMCron.py script, I came across the following bug. My problem was that the 'get_mail' task was being process the first time after Zope initialisation, but would error every time afterwards with "Failure to get lock for get_mail" in the logs.

I tracked it down to a problem caused by the ZSQL method used to release the MySQL database locks (when processing the tasks called by 'process_tasks') being broken.

If we look at the MySQL-specific statement used in getCronLock.zsql, we can see that it does the following:

SELECT GET_LOCK('cron_<dtml-var sqv_lock_name>', 5) AS lockval

However, if we look at the MySQL statement used in releaseCronLock.zsql, it does this:

SELECT RELEASE_LOCK('<dtml-var sqv_lock_name>') AS lockval

Spot the mistake? The lock string name on the release call isn't the same! It's missing the 'cron_' prefix. This means that ANY locks set in MySQL would never actually be released, no matter what!

It should obviously be corrected to:

SELECT RELEASE_LOCK('cron_<dtml-var sqv_lock_name>') AS lockval

Discussion


Log in to post a comment.