Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

DB connection timeout

Go to End



Community Member, 6 Posts

7 June 2013 at 3:20am

I've created a class that extends DailyTask to use for a cron job. What the task does is download several large files from a government bureau and insert those csv files into temp tables. Each function in the class works correctly, however, when I run them all together I start gettings errors saying "MySQL server has gone away." on simple DB::query() calls using insert statements. If, however, I remove the function to download the files (and manually upload the files to the proper directory), it executes without a problem and actually inserts the data into the temp tables.

From what I have been able to find online, the MySQL error is most often caused by a timeout. Is there a way to delay the Silverstripe database connection until right before it's needed to allow the files to be downloaded from the remote FTP first? Or should I close the connection and reopen it right before needing it?

I've attached a screenshot of my shell window when running the task with Sake. Any insight would be greatly appreciated.