From d979e54030b0069572affe173c06680597cc831d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 10 Aug 2015 14:39:34 +0200 Subject: log a warning while trying to acquire a db lock from within a transaction --- lib/private/lock/dblockingprovider.php | 14 +++++++++++++- lib/private/server.php | 8 ++++---- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php index 5480a6e53af..5241a0440b3 100644 --- a/lib/private/lock/dblockingprovider.php +++ b/lib/private/lock/dblockingprovider.php @@ -22,6 +22,7 @@ namespace OC\Lock; use OCP\IDBConnection; +use OCP\ILogger; use OCP\Lock\LockedException; /** @@ -33,11 +34,18 @@ class DBLockingProvider extends AbstractLockingProvider { */ private $connection; + /** + * @var \OCP\ILogger + */ + private $logger; + /** * @param \OCP\IDBConnection $connection + * @param \OCP\ILogger $logger */ - public function __construct(IDBConnection $connection) { + public function __construct(IDBConnection $connection, ILogger $logger) { $this->connection = $connection; + $this->logger = $logger; } protected function initLockField($path) { @@ -68,6 +76,10 @@ class DBLockingProvider extends AbstractLockingProvider { * @throws \OCP\Lock\LockedException */ public function acquireLock($path, $type) { + if ($this->connection->inTransaction()){ + $this->logger->warning('Trying to acquire a lock while inside a transition'); + } + $this->connection->beginTransaction(); $this->initLockField($path); if ($type === self::LOCK_SHARED) { diff --git a/lib/private/server.php b/lib/private/server.php index 51e70405432..be2cfc2cf88 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -432,10 +432,10 @@ class Server extends SimpleContainer implements IServerContainer { /** @var \OC\Memcache\Factory $memcacheFactory */ $memcacheFactory = $c->getMemCacheFactory(); $memcache = $memcacheFactory->createLocking('lock'); - if (!($memcache instanceof \OC\Memcache\NullCache)) { - return new MemcacheLockingProvider($memcache); - } - return new DBLockingProvider($c->getDatabaseConnection()); +// if (!($memcache instanceof \OC\Memcache\NullCache)) { +// return new MemcacheLockingProvider($memcache); +// } + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger()); } return new NoopLockingProvider(); }); -- cgit v1.2.3