File upload causes SQL lock timeout

The web site allows users to upload files and currently stores +400,000 files. These files can be large PDF files. We have moved to a new server and the user is receiving a “Gateway Timeout” error after 90s when uploading a file. The file uploads successfully, however I also see this error in the log, usually in groups of 2 or 3 users within seconds of each other:

SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

The SQL statement causing this error is:
UPDATE TreeNodes SET dateModified = ? WHERE treeNodeID = ?’ with params [“2024-09-04 13:39:41”, “7”]:

Tree Node record ID=7 refers to the root folder of the file repository. A second attempt to upload the file typically succeeds. This is an intermittent error, not repeatable. Any advice on why this query would be receiving a timeout?

Concrete CMS version: 9.2.4

Not off the top of my head - might be worth talking to your hosting provider about just in case it’s something SQL configuration specific.

I would recommend updating your Concrete version if possible - sometimes that eliminates these little oddities.

Hello Evan - Thank you for the feedback. We have been working very closely with our hosting provider for access to system and database logs. We have determined that the ConcreteCMS file delete method is taking 4 to 5 minutes to complete. We do not see a query holding a lock during this time, but the lock timeout errors accumulate for subsequent file uploads/queries during this time.

Our solution is to move the file delete operation to an “offline” process. As we develop the offline process we will dive deeper into the ConcreteCMS file delete code in an attempt to determine why the delete process takes so long to complete (as this will limit when we can run this process).

Any direction or insight that you can provide as we research this further is appreciated. Thank you.

Speed Analyzer GitHub - a3020/speed_analyzer: Analyze the loading times of your pages in concrete5 (8.2.1+) may help. It will likely need updating to work with 9.3. and php8.