Hi,
Okay, weird problem time.
A SS site I deployed, working just fine on the dev server, has choked up on a shared server (MediaTemple). Just updated to 2.2.1, and weirdness is happening.
Specifically, the site itself is okay, and the admin section works, EXCEPT for the Files and Images section. This was working once, but now it's broken.
It throws a 500 Internal Server Error - I found where in the Debug.php file and put in its friendly stack trace. Here's the test (domain edited out for safety):
-----
Debug::friendlyError(256,DATABASE ERROR: Couldn't run query: SELECT Name FROM `File` WHERE ParentID = 0 GROUP BY Name HAVING count(*) > 1 | Can't create/write to file '/tmp/#sql_3db3_0.MYI' (Errcode: 17),/[myserver.com]/html/sapphire/core/model/Database.php,397,Array)
line 115 of Debug.php
Debug::fatalHandler(256,DATABASE ERROR: Couldn't run query: SELECT Name FROM `File` WHERE ParentID = 0 GROUP BY Name HAVING count(*) > 1 | Can't create/write to file '/tmp/#sql_3db3_0.MYI' (Errcode: 17),/[myserver.com]/html/sapphire/core/model/Database.php,397,Array)
line 328 of Debug.php
errorHandler(256,DATABASE ERROR: Couldn't run query: SELECT Name FROM `File` WHERE ParentID = 0 GROUP BY Name HAVING count(*) > 1 | Can't create/write to file '/tmp/#sql_3db3_0.MYI' (Errcode: 17),/[myserver.com]/html/sapphire/core/model/Database.php,397,Array)
user_error(DATABASE ERROR: Couldn't run query: SELECT Name FROM `File` WHERE ParentID = 0 GROUP BY Name HAVING count(*) > 1 | Can't create/write to file '/tmp/#sql_3db3_0.MYI' (Errcode: 17),256)
line 397 of Database.php
Database->databaseError(Couldn't run query: SELECT Name FROM `File` WHERE ParentID = 0 GROUP BY Name HAVING count(*) > 1 | Can't create/write to file '/tmp/#sql_3db3_0.MYI' (Errcode: 17),256)
line 106 of MySQLDatabase.php
MySQLDatabase->query(SELECT Name FROM `File` WHERE ParentID = 0 GROUP BY Name HAVING count(*) > 1,256)
line 79 of DB.php
DB::query(SELECT Name FROM `File` WHERE ParentID = 0 GROUP BY Name HAVING count(*) > 1)
line 73 of Folder.php
Folder->syncChildren()
line 211 of File.php
File::sync()
line 78 of AssetAdmin.php
AssetAdmin->index(Array)
line 210 of Controller.php
Controller->run(Array)
line 76 of Director.php
Director::direct(admin/assets/)
line 104 of main.php
-----
I've tried flushing the cache, rebuilding the database, and trying to find where the heck it's trying to write to /tmp/ (which is not available on the shared host, so I'm using the silverstripe-cache folder in the web root).
It's only started happening recently, and I'm not sure why - or how to fix it. All other admin functions are working as expected.
Any ideas, thoughts etc. appreciated. Thanks.
[EDIT]
Okay, seems to be a MySQL infrequent problem. Specifically, here: http://bugs.mysql.com/bug.php?id=9551
My solution, whilst inelegant, was to DROP the File table, and then run a /db/build?flush=1 to recreate it.