500 error: uploading files (duplicate primary key) Afternoon all - odd issue where created some new asset folders and adding new files is timing out. If I view the folder in question (on the server) I can see the file has been successfully uploaded but this isn’t reflected in the back-end. Craft 2.4. Console Log is returning a POST /admin/actions/assets/uploadFile 500 (Internal Server Error) response. 

Checking the craft logs it is throwing a Duplicate entry '3996' for key 'PRIMARY' error in the craft_assetfiles table. It looks like somewhere between builds/deployments the craft_assetfiles table has got out of sync. I've tried updating the Asset and Search indexes but with no success. 

Any thoughts on debugging or resolving?
Okay - have managed to resolve this. Needed to reset the auto increment value in the craft_elements to greater than the max(id) for the craft_assetfiles - not sure how those got out of synch but that seems to have resolved it. Hallelujah!