Skip to content
Extraits de code Groupes Projets
Valider 37b0c37b rédigé par Benaka Moorthi's avatar Benaka Moorthi
Parcourir les fichiers

Move deadlock info logging to Db.php, fix core updater translation regression,...

Move deadlock info logging to Db.php, fix core updater translation regression, fix core updater css regression, change logger_message level column to string, and delete unneeded logger tables if not empty. Also includes some changes to travis build.
parent c94adb68
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -48,7 +48,7 @@ after_success: ...@@ -48,7 +48,7 @@ after_success:
after_script: after_script:
- cat /var/log/nginx/error.log - cat /var/log/nginx/error.log
- cat $TRAVIS_BUILD_DIR/../piwik/tmp/php-fpm.log - cat $TRAVIS_BUILD_DIR/../piwik/tmp/php-fpm.log
- cat $TRAVIS_BUILD_DIR/../piwik/tmp/logs/logger_message.htm - cat $TRAVIS_BUILD_DIR/../piwik/tmp/logs/piwik.log
- cd $TRAVIS_BUILD_DIR - cd $TRAVIS_BUILD_DIR
- ./tests/travis/upload_artifacts.sh - ./tests/travis/upload_artifacts.sh
......
...@@ -127,15 +127,7 @@ class ArchiveWriter ...@@ -127,15 +127,7 @@ class ArchiveWriter
'" . $date . "', '" . $date . "',
0 " 0 "
. " FROM $numericTable as tb1"; . " FROM $numericTable as tb1";
try { // TODO: this is temporary, remove when deadlocking issue is fixed Db::get()->exec($insertSql);
Db::get()->exec($insertSql);
} catch (Exception $ex) {
if (Db::get()->isErrNo($ex, 1213)) {
$deadlockInfo = \Piwik\Db::fetchAll("SHOW ENGINE INNODB STATUS");
Log::debug("DEADLOCK INFO: " . print_r($deadlockInfo));
}
throw $ex;
}
$this->releaseArchiveTableLock(); $this->releaseArchiveTableLock();
$selectIdSql = "SELECT idarchive FROM $numericTable WHERE name = ? LIMIT 1"; $selectIdSql = "SELECT idarchive FROM $numericTable WHERE name = ? LIMIT 1";
$id = Db::get()->fetchOne($selectIdSql, $locked); $id = Db::get()->fetchOne($selectIdSql, $locked);
......
...@@ -81,7 +81,14 @@ class Db ...@@ -81,7 +81,14 @@ class Db
$db = self::get(); $db = self::get();
$profiler = $db->getProfiler(); $profiler = $db->getProfiler();
$q = $profiler->queryStart($sql, \Zend_Db_Profiler::INSERT); $q = $profiler->queryStart($sql, \Zend_Db_Profiler::INSERT);
$return = self::get()->exec($sql);
try {
$return = self::get()->exec($sql);
} catch (Exception $ex) {
self::logExtraInfoIfDeadlock($ex);
throw $ex;
}
$profiler->queryEnd($q); $profiler->queryEnd($q);
return $return; return $return;
} }
...@@ -98,7 +105,12 @@ class Db ...@@ -98,7 +105,12 @@ class Db
*/ */
static public function query($sql, $parameters = array()) static public function query($sql, $parameters = array())
{ {
return self::get()->query($sql, $parameters); try {
return self::get()->query($sql, $parameters);
} catch (Exception $ex) {
self::logExtraInfoIfDeadlock($ex);
throw $ex;
}
} }
/** /**
...@@ -110,7 +122,12 @@ class Db ...@@ -110,7 +122,12 @@ class Db
*/ */
static public function fetchAll($sql, $parameters = array()) static public function fetchAll($sql, $parameters = array())
{ {
return self::get()->fetchAll($sql, $parameters); try {
return self::get()->fetchAll($sql, $parameters);
} catch (Exception $ex) {
self::logExtraInfoIfDeadlock($ex);
throw $ex;
}
} }
/** /**
...@@ -122,7 +139,12 @@ class Db ...@@ -122,7 +139,12 @@ class Db
*/ */
static public function fetchRow($sql, $parameters = array()) static public function fetchRow($sql, $parameters = array())
{ {
return self::get()->fetchRow($sql, $parameters); try {
return self::get()->fetchRow($sql, $parameters);
} catch (Exception $ex) {
self::logExtraInfoIfDeadlock($ex);
throw $ex;
}
} }
/** /**
...@@ -134,7 +156,12 @@ class Db ...@@ -134,7 +156,12 @@ class Db
*/ */
static public function fetchOne($sql, $parameters = array()) static public function fetchOne($sql, $parameters = array())
{ {
return self::get()->fetchOne($sql, $parameters); try {
return self::get()->fetchOne($sql, $parameters);
} catch (Exception $ex) {
self::logExtraInfoIfDeadlock($ex);
throw $ex;
}
} }
/** /**
...@@ -146,7 +173,12 @@ class Db ...@@ -146,7 +173,12 @@ class Db
*/ */
static public function fetchAssoc($sql, $parameters = array()) static public function fetchAssoc($sql, $parameters = array())
{ {
return self::get()->fetchAssoc($sql, $parameters); try {
return self::get()->fetchAssoc($sql, $parameters);
} catch (Exception $ex) {
self::logExtraInfoIfDeadlock($ex);
throw $ex;
}
} }
/** /**
...@@ -469,4 +501,13 @@ class Db ...@@ -469,4 +501,13 @@ class Db
return self::$lockPrivilegeGranted; return self::$lockPrivilegeGranted;
} }
} private static function logExtraInfoIfDeadlock($ex)
{
if (self::get()->isErrNo($ex, 1213)) {
$deadlockInfo = self::fetchAll("SHOW ENGINE INNODB STATUS");
// log using exception so backtrace appears in log output
Log::debug(new Exception("Encountered deadlock: " . print_r($deadlockInfo, true)));
}
}
}
\ No newline at end of file
...@@ -399,7 +399,7 @@ class Log ...@@ -399,7 +399,7 @@ class Log
$sql = "INSERT INTO " . Common::prefixTable('logger_message') $sql = "INSERT INTO " . Common::prefixTable('logger_message')
. " (tag, timestamp, level, message)" . " (tag, timestamp, level, message)"
. " VALUES (?, ?, ?, ?)"; . " VALUES (?, ?, ?, ?)";
Db::query($sql, array($tag, $datetime, $level, (string)$message)); Db::query($sql, array($tag, $datetime, self::getStringLevel($level), (string)$message));
} }
private function doLog($level, $message, $sprintfParams = array()) private function doLog($level, $message, $sprintfParams = array())
......
...@@ -71,6 +71,16 @@ class Twig ...@@ -71,6 +71,16 @@ class Twig
$this->addFunction_sparkline(); $this->addFunction_sparkline();
$this->addFunction_postEvent(); $this->addFunction_postEvent();
$this->addFunction_isPluginLoaded(); $this->addFunction_isPluginLoaded();
$this->addFunction_getJavascriptTranslations();
}
protected function addFunction_getJavascriptTranslations()
{
$getJavascriptTranslations = new Twig_SimpleFunction(
'getJavascriptTranslations',
array(Translate::getInstance(), 'getJavascriptTranslations')
);
$this->twig->addFunction($getJavascriptTranslations);
} }
protected function addFunction_isPluginLoaded() protected function addFunction_isPluginLoaded()
......
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik
* @package Piwik
*/
use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;
use Piwik\Db;
/**
* @package Updates
*/
class Piwik_Updates_2_0_a12 extends Updates
{
public static function getSql($schema = 'Myisam')
{
$result = array(
'ALTER TABLE ' . Common::prefixTable('logger_message') . ' MODIFY level VARCHAR(16) NULL' => false
);
$unneededLogTables = array('logger_exception', 'logger_error', 'logger_api_call');
foreach ($unneededLogTables as $table) {
$tableName = Common::prefixTable($table);
try {
$rows = Db::fetchOne("SELECT COUNT(*) FROM $tableName");
if ($rows == 0) {
$result["DROP TABLE $tableName"] = false;
}
} catch (Exception $ex) {
// ignore
}
}
return $result;
}
public static function update()
{
// change level column in logger_message table to string & remove other logging tables if empty
Updater::updateDatabase(__FILE__, self::getSql());
}
}
\ No newline at end of file
...@@ -22,5 +22,5 @@ final class Version ...@@ -22,5 +22,5 @@ final class Version
* Current Piwik version * Current Piwik version
* @var string * @var string
*/ */
const VERSION = '2.0-a11'; const VERSION = '2.0-a12';
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<script type="text/javascript" src="libs/jquery/jquery-ui.js"></script> <script type="text/javascript" src="libs/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="plugins/CoreHome/javascripts/donate.js"></script> <script type="text/javascript" src="plugins/CoreHome/javascripts/donate.js"></script>
<script type="text/javascript" src="plugins/CoreUpdater/javascripts/updateLayout.js"></script> <script type="text/javascript" src="plugins/CoreUpdater/javascripts/updateLayout.js"></script>
<script type="text/javascript" src="index.php?module=Proxy&action=getTranslationJs"></script> <script type="text/javascript">{{ getJavascriptTranslations()|raw }}</script>
{% if 'General_LayoutDirection'|translate =='rtl' %} {% if 'General_LayoutDirection'|translate =='rtl' %}
<link rel="stylesheet" type="text/css" href="plugins/Zeitgeist/stylesheets/rtl.css"/> <link rel="stylesheet" type="text/css" href="plugins/Zeitgeist/stylesheets/rtl.css"/>
{% endif %} {% endif %}
......
...@@ -597,6 +597,7 @@ class Controller extends \Piwik\Controller\Admin ...@@ -597,6 +597,7 @@ class Controller extends \Piwik\Controller\Admin
*/ */
public function getBaseCss() public function getBaseCss()
{ {
@header('Content-Type: text/css');
echo AssetManager::getCompiledBaseCss(); echo AssetManager::getCompiledBaseCss();
} }
......
Subproject commit bfc771d9a6df886f9c149375e021b41d33bc11b4 Subproject commit e7b93068ef7df84cfdaa912ec613d9abb1a737fb
...@@ -35,6 +35,10 @@ class Test_Piwik_JsProxy extends PHPUnit_Framework_TestCase ...@@ -35,6 +35,10 @@ class Test_Piwik_JsProxy extends PHPUnit_Framework_TestCase
curl_close($curlHandle); curl_close($curlHandle);
$this->assertEquals($responseInfo["http_code"], 200, 'Ok response'); $this->assertEquals($responseInfo["http_code"], 200, 'Ok response');
if ("R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" != base64_encode($fullResponse)) {
\Piwik\Log::info("testPiwikPhp invalid response content: " . $fullResponse);
}
$this->assertEquals( $this->assertEquals(
"R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==", "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",
base64_encode($fullResponse), base64_encode($fullResponse),
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter