Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-03-04 17:42:35 +0300
committerMorris Jobke <hey@morrisjobke.de>2016-03-04 22:13:05 +0300
commit9737290e3915a5565618e8db6a5decd42c8a794e (patch)
treee07692d6c0327658a36905d4ea95c7ca07f360b3 /lib
parentbb0c3044820aab0b396b5ddc3387183e0212a5cc (diff)
Run cleanup of expired DB file locks to background job
* fixes #22819 The old way fired a DELETE statement on each destruction of the DBLockingProvider. Which could cause a lot of queries. It's enough to run this every 5 minutes in a background job, which in the end could result in file locks that exists 5 minutes longer - in the worst case and for not properly released locks. This makes the DB based locking a lot more performant and could result in a similar performance to the Redis based locking provider.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/lock/dblockingprovider.php26
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php
index 647250cdb6f..c10cd8636ad 100644
--- a/lib/private/lock/dblockingprovider.php
+++ b/lib/private/lock/dblockingprovider.php
@@ -235,10 +235,17 @@ class DBLockingProvider extends AbstractLockingProvider {
*/
public function cleanExpiredLocks() {
$expire = $this->timeFactory->getTime();
- $this->connection->executeUpdate(
- 'DELETE FROM `*PREFIX*file_locks` WHERE `ttl` < ?',
- [$expire]
- );
+ try {
+ $this->connection->executeUpdate(
+ 'DELETE FROM `*PREFIX*file_locks` WHERE `ttl` < ?',
+ [$expire]
+ );
+ } catch (\Exception $e) {
+ // If the table is missing, the clean up was successful
+ if ($this->connection->tableExists('file_locks')) {
+ throw $e;
+ }
+ }
}
/**
@@ -257,15 +264,4 @@ class DBLockingProvider extends AbstractLockingProvider {
}
}
}
-
- public function __destruct() {
- try {
- $this->cleanExpiredLocks();
- } catch (\Exception $e) {
- // If the table is missing, the clean up was successful
- if ($this->connection->tableExists('file_locks')) {
- throw $e;
- }
- }
- }
}