Instrumented the code to help in solving the "restore runing" issue. Retrofit from trunk of [3733] and [3595]: better error handling... check error.log!

SVN:2.1.0[3738]
This commit is contained in:
Romain Quetiez
2015-09-09 09:44:39 +00:00
parent 9f1338ee2a
commit 86e6c8295f
3 changed files with 11 additions and 6 deletions

View File

@@ -133,7 +133,9 @@ class iTopMutex
}
if (($res !== '1') && ($res !== '0'))
{
IssueLog::Error('GET_LOCK('.$this->sName.', 0) returned: '.var_export($res, true).'. Expected values are: 0, 1 or null !!');
$sMsg = 'GET_LOCK('.$this->sName.', 0) returned: '.var_export($res, true).'. Expected values are: 0, 1 or null';
IssueLog::Error($sMsg);
throw new Exception($sMsg);
}
return ($res !== '0');
}

View File

@@ -1,5 +1,5 @@
<?php
// Copyright (C) 2014 Combodo SARL
// Copyright (C) 2013-2015 Combodo SARL
//
// This file is part of iTop.
//
@@ -19,7 +19,7 @@
/**
* Backup from an interactive session
*
* @copyright Copyright (C) 2013 Combodo SARL
* @copyright Copyright (C) 2013-215 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
@@ -119,7 +119,9 @@ EOF
{
$sEnvironment = utils::ReadParam('environment', 'production', false, 'raw_data');
$oRestoreMutex = new iTopMutex('restore.'.$sEnvironment);
IssueLog::Info("Backup Restore - Acquiring the LOCK 'restore.$sEnvironment'");
$oRestoreMutex->Lock();
IssueLog::Info('Backup Restore - LOCK acquired, executing...');
try
{
set_time_limit(0);
@@ -144,6 +146,7 @@ EOF
$sBackupFile = $sBackupDir.$sFile;
$sRes = $oDBRS->RestoreFromZip($sBackupFile, $sEnvironment);
IssueLog::Info('Backup Restore - Done, releasing the LOCK');
$oRestoreMutex->Unlock();
}
catch (Exception $e)

View File

@@ -1,5 +1,5 @@
<?php
// Copyright (C) 2014 Combodo SARL
// Copyright (C) 2014-2015 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -26,7 +26,6 @@ class BackupHandler extends ModuleHandlerAPI
{
public static function OnMetaModelStarted()
{
try
{
$oBackupMutex = new iTopMutex('backup.'.utils::GetCurrentEnvironment());
@@ -48,13 +47,14 @@ class BackupHandler extends ModuleHandlerAPI
}
else
{
IssueLog::Info(__class__.'::'.__function__.' A user is trying to use iTop while a restore is running. The requested page is in read-only mode.');
MetaModel::GetConfig()->Set('access_mode', ACCESS_READONLY, 'itop-backup');
MetaModel::GetConfig()->Set('access_message', ' - '.dict::S('bkp-restore-running'), 'itop-backup');
}
}
catch(Exception $e)
{
IssueLog::Error(__class__.'::'.__function__.' Failed to check if a backup/restore is running: '.$e->getMessage());
}
}
}