[BUGFIX] Reestablish DB connection in long-running tasks 65/42665/2
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Wed, 12 Aug 2015 18:31:33 +0000 (20:31 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Mon, 17 Aug 2015 06:28:24 +0000 (08:28 +0200)
During a long-running task the connection to the database may be
disconnected, if mysql `wait_timeout` is exceeded. This patch makes
sure the connection is reestablished if there has been a connection
before.

Resolves: #69001
Releases: master, 6.2
Change-Id: I7575ae386ec190d60ddceee146133125083dee41
Reviewed-on: http://review.typo3.org/42665
Reviewed-by: Josef Glatz <jousch@gmail.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/core/Classes/Database/DatabaseConnection.php
typo3/sysext/scheduler/Classes/Scheduler.php

index b0162b4..d0808b4 100644 (file)
@@ -1613,6 +1613,9 @@ class DatabaseConnection {
                if ($this->isConnected) {
                        // Check if this is really the case or if the database server has gone away for some reason
                        $this->isConnected = $this->link->ping();
+                       if (!$this->isConnected) {
+                               $this->connectDB();
+                       }
                }
                return $this->isConnected;
        }
index 7724949..2a05e7e 100644 (file)
@@ -153,6 +153,9 @@ class Scheduler implements \TYPO3\CMS\Core\SingletonInterface {
                                // Store exception, so that it can be saved to database
                                $failure = $e;
                        }
+                       // make sure database-connection is fine
+                       // for long-running tasks the database might meanwhile have disconnected
+                       $this->getDatabaseConnection()->isConnected();
                        // Un-register execution
                        $task->unmarkExecution($executionID, $failure);
                        // Log completion of execution