Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw Exception if lockfile could not be obtained #793

Merged
merged 2 commits into from
Feb 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions classes/ETL/LockFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ protected function generateLockfileName($pid = null)
*
* @param array $actionList A list of action names to be executed by this ETL process.
*
* @return boolean TRUE if the lock was generated, FALSE otherwise.
* @return boolean TRUE if the lock was generated.
*
* @throws Exception If a process is already running with overlapping actions.
* @throws Exception If the lock could not be obtained.
* ------------------------------------------------------------------------------------------
*/

Expand All @@ -140,10 +143,9 @@ public function lock(array $actionList)

if ( false === ($dh = opendir($this->lockDir)) ) {
$error = error_get_last();
$this->logger->warning(
$this->logAndThrowException(
sprintf("Error opening lock directory '%s': %s", $this->lockDir, $error['message'])
);
return false;
}

// Cleanup any lockfiles not associated with a running process
Expand Down Expand Up @@ -188,10 +190,9 @@ public function lock(array $actionList)

if ( false === ($fp = @fopen($lockFile, 'w')) ) {
$error = error_get_last();
$this->logger->warning(
$this->logAndThrowException(
sprintf("Error creating lock file '%s': %s", $lockFile, $error['message'])
);
return false;
}

// Obtain an advisory lock. This advisory will be memoved if the process dies or
Expand Down