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.

Data Model Questions /

DB connection timeout


Reply


423 Views

Avatar
r0nn1ef

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.