[VBB-960] Scheduled Tasks: MySQL error due to tables with the same name in rare cases > nEwZ - sCRiPTz-TEAM.iNFO

Canal Rss Canal Rss
Canal Atom Canal Atom 

[VBB-960] Scheduled Tasks: MySQL error due to tables with the same name in rare cases

Category: vBulletin - Blog
Viewed: 42 times
Printerfriendly version version of Microsoft Word HTML version

Same as this bug for vB4 - http://tracker.vbulletin.com/browse/VBIV-8893

The scheduled tasks may create an MySQL error due to tables with the same name in rare cases:

Invalid SQL:

    INSERT INTO blog_aggregate_temp_1283942100
    (entries, userid)
    SELECT COUNT(blogid) AS total, userid
    FROM blog
    WHERE dateline >= 1283842800
    AND dateline < 1283929200
    AND pending = 0
    AND state = 'visible'
    GROUP BY userid;

    MySQL-error: Unknown column 'entries' in 'field list'
    Error : 1054
    Time : Wednesday, 08.09.2010 @ 03:35:18
    Date : Wednesday, 08.09.2010 @ 03:35:18
    Script : http://www.vbulletin-germany.com/forum/cron.php?rand=1283942116

I think the reason is because the scheduled tasks "blog_views.php" and "blog_dailycleanup.php" are using the same base name for the temporary table (blog_aggregate_temp_$nextitem[nextrun]) and when those cron jobs run at the same time, it creates a conflict. I now have seen it three times (one ticket, one post in the forums ( http://www.vbulletin.com/forum/showthread.php?353175-Blog-DB-error ) and today on vbulletin-germany.com).

Proposed fix:

Change the table base name in one of those scripts, i.e. edit /includes/cron/blog_dailycleanup.php and search:

$aggtable = "blog_aggregate_temp_$nextitem[nextrun]";

Change it to:

$aggtable = "blog_aggregate_tempdc_$nextitem[nextrun]";

Fri, 28 January 2011