Skip to content

Locks are removed on next cron run #1016

@susnux

Description

@susnux

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Summary

From the code:

public function getDeprecatedLocks(int $limit = 0): array {
$timeout = (int)$this->configService->getAppValue(ConfigService::LOCK_TIMEOUT);
if ($timeout === 0) {
$this->logger->notice(
'ConfigService::LOCK_TIMEOUT is not numerical, using default', ['current' => $timeout, 'exception' => new \Exception()]
);
$timeout = (int)$this->configService->defaults[ConfigService::LOCK_TIMEOUT];
}
try {
$locks = $this->locksRequest->getLocksOlderThan($timeout, $limit);
} catch (Exception $e) {
$this->logger->warning('Failed to get locks older then timeout', ['exception' => $e]);
return [];
}
return $locks;
}

It is called by the cron to cleanup old locks.
Now if there is no limit the default of 0 is taken.
But then all locks are queried which have creation time < now - timeout -> creation time < now so basically all locks are unlocked.

Meaning all locks are expired between 0 and 720 seconds after creation (if the cron job runs)

Expected behavior

The documentation (README) says:

Locks have no expiry by default.

This is also confirmed by @nextcloud/designers to be the intended behavior, so that users by default have to manually remove their set locks.

Suggested fix

If the timeout is not set (=== '') it should default to -1 in which case the expiry is skipped.
If a timeout of 0 is explicitly configured it should keep current (faulty) behavior of expire ASAP, to have a way for some instances that really wanted this behavior.

cc @benjaminfrueh

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions