summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-05-04 13:30:18 +0200
committerRobin Appelman <robin@icewind.nl>2018-05-04 13:35:26 +0200
commita070c1177a80adb6db608e196df8a1a1056be64f (patch)
tree83bfa719bdaa4408300d365d2d6d8e448613a8b9 /lib/private
parent642ebea4902c57ea2e536f9389602f3061572af1 (diff)
downloadnextcloud-server-a070c1177a80adb6db608e196df8a1a1056be64f.tar.gz
nextcloud-server-a070c1177a80adb6db608e196df8a1a1056be64f.zip
Log more info about locking conflicts for memcache locking backends
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Lock/MemcacheLockingProvider.php19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/private/Lock/MemcacheLockingProvider.php b/lib/private/Lock/MemcacheLockingProvider.php
index c4b1469b50f..ddd73aec095 100644
--- a/lib/private/Lock/MemcacheLockingProvider.php
+++ b/lib/private/Lock/MemcacheLockingProvider.php
@@ -71,12 +71,12 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
public function acquireLock($path, $type) {
if ($type === self::LOCK_SHARED) {
if (!$this->memcache->inc($path)) {
- throw new LockedException($path);
+ throw new LockedException($path, null, $this->getExistingLockForException($path));
}
} else {
$this->memcache->add($path, 0);
if (!$this->memcache->cas($path, 0, 'exclusive')) {
- throw new LockedException($path);
+ throw new LockedException($path, null, $this->getExistingLockForException($path));
}
}
$this->setTTL($path);
@@ -114,15 +114,26 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
public function changeLock($path, $targetType) {
if ($targetType === self::LOCK_SHARED) {
if (!$this->memcache->cas($path, 'exclusive', 1)) {
- throw new LockedException($path);
+ throw new LockedException($path, null, $this->getExistingLockForException($path));
}
} else if ($targetType === self::LOCK_EXCLUSIVE) {
// we can only change a shared lock to an exclusive if there's only a single owner of the shared lock
if (!$this->memcache->cas($path, 1, 'exclusive')) {
- throw new LockedException($path);
+ throw new LockedException($path, null, $this->getExistingLockForException($path));
}
}
$this->setTTL($path);
$this->markChange($path, $targetType);
}
+
+ private function getExistingLockForException($path) {
+ $existing = $this->memcache->get($path);
+ if (!$existing) {
+ return 'none';
+ } else if ($existing === 'exclusive') {
+ return $existing;
+ } else {
+ return $existing . ' shared locks';
+ }
+ }
}