Skip to content

Commit

Permalink
Added database name to lock name in MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
fabik authored and JanTvrdik committed Jan 14, 2016
1 parent 7fddb41 commit dba6509
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Drivers/MySqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function rollbackTransaction()
public function lock()
{
$lock = $this->dbal->escapeString(self::LOCK_NAME);
$result = (int) $this->dbal->query("SELECT GET_LOCK($lock, 3) AS `result`")[0]['result'];
$result = (int) $this->dbal->query("SELECT GET_LOCK(CONCAT($lock, '-', DATABASE()), 3) AS `result`")[0]['result'];
if ($result !== 1) {
throw new LockException('Unable to acquire a lock.');
}
Expand All @@ -76,7 +76,7 @@ public function lock()
public function unlock()
{
$lock = $this->dbal->escapeString(self::LOCK_NAME);
$result = (int) $this->dbal->query("SELECT RELEASE_LOCK($lock) AS `result`")[0]['result'];
$result = (int) $this->dbal->query("SELECT RELEASE_LOCK(CONCAT($lock, '-', DATABASE())) AS `result`")[0]['result'];
if ($result !== 1) {
throw new LockException('Unable to release a lock.');
}
Expand Down

0 comments on commit dba6509

Please sign in to comment.