clear, readme

This commit is contained in:
Robin Appelman 2022-08-03 16:56:38 +02:00
commit 2fa6f5d552
4 changed files with 115 additions and 0 deletions

56
README.md Normal file
View file

@ -0,0 +1,56 @@
# Lockpick
Debug transactional locking conflicts
## How
- Enable the app
- Create a conflict
- Run `occ lockpick:show`
- Debug
## Example output
```text
Conflict detected between 2 locks
exclusive lock from
OC\Files\Storage\Common->changeLock - lib/private/Files/Storage/Wrapper/Wrapper.php 632
OC\Files\Storage\Wrapper\Wrapper->changeLock - lib/private/Files/Storage/Wrapper/Wrapper.php 632
OC\Files\Storage\Wrapper\Wrapper->changeLock - lib/private/Files/View.php 2001
OC\Files\View->changeLock - apps/dav/lib/Connector/Sabre/Node.php 446
OCA\DAV\Connector\Sabre\Node->changeLock - apps/dav/lib/Connector/Sabre/File.php 191
OCA\DAV\Connector\Sabre\File->put - apps/dav/lib/Connector/Sabre/Directory.php 151
OCA\DAV\Connector\Sabre\Directory->createFile - 3rdparty/sabre/dav/lib/DAV/Server.php 1098
Sabre\DAV\Server->createFile - 3rdparty/sabre/dav/lib/DAV/CorePlugin.php 504
Sabre\DAV\CorePlugin->httpPut - 3rdparty/sabre/event/lib/WildcardEmitterTrait.php 89
Sabre\DAV\Server->emit - 3rdparty/sabre/dav/lib/DAV/Server.php 472
Sabre\DAV\Server->invokeMethod - 3rdparty/sabre/dav/lib/DAV/Server.php 253
Sabre\DAV\Server->start - 3rdparty/sabre/dav/lib/DAV/Server.php 321
Sabre\DAV\Server->exec - apps/dav/appinfo/v1/webdav.php 85
require_once - remote.php 167
shared lock from
OC\Files\Storage\Common->acquireLock - lib/private/Files/Storage/Wrapper/Wrapper.php 610
OC\Files\Storage\Wrapper\Wrapper->acquireLock - lib/private/Files/Storage/Wrapper/Wrapper.php 610
OC\Files\Storage\Wrapper\Wrapper->acquireLock - lib/private/Files/Cache/Scanner.php 149
OC\Files\Cache\Scanner->scanFile - apps/files_sharing/lib/External/Scanner.php 57
OCA\Files_Sharing\External\Scanner->scanFile - lib/private/Files/Cache/Scanner.php 340
OC\Files\Cache\Scanner->scan - apps/files_sharing/lib/External/Scanner.php 39
OCA\Files_Sharing\External\Scanner->scan - lib/private/Files/Cache/Updater.php 125
OC\Files\Cache\Updater->update - apps/dav/lib/Connector/Sabre/File.php 368
OCA\DAV\Connector\Sabre\File->put - apps/dav/lib/Connector/Sabre/Directory.php 151
OCA\DAV\Connector\Sabre\Directory->createFile - 3rdparty/sabre/dav/lib/DAV/Server.php 1098
Sabre\DAV\Server->createFile - 3rdparty/sabre/dav/lib/DAV/CorePlugin.php 504
Sabre\DAV\CorePlugin->httpPut - 3rdparty/sabre/event/lib/WildcardEmitterTrait.php 89
Sabre\DAV\Server->emit - 3rdparty/sabre/dav/lib/DAV/Server.php 472
Sabre\DAV\Server->invokeMethod - 3rdparty/sabre/dav/lib/DAV/Server.php 253
Sabre\DAV\Server->start - 3rdparty/sabre/dav/lib/DAV/Server.php 321
Sabre\DAV\Server->exec - apps/dav/appinfo/v1/webdav.php 85
require_once - remote.php 167
```
## Commands
- `occ lockpick:list` show all stored conflict traces
- `occ lockpick:show <id>` show a stored trace, defaults to the latest
- `occ lockpick:clear` remove all stored traces

View file

@ -18,6 +18,7 @@
<commands>
<command>OCA\LockPick\Command\Show</command>
<command>OCA\LockPick\Command\Clear</command>
<command>OCA\LockPick\Command\ListCommand</command>
</commands>
</info>

52
lib/Command/Clear.php Normal file
View file

@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\LockPick\Command;
use OC\Core\Command\Base;
use OCA\LockPick\TraceStore;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Clear extends Base {
private TraceStore $store;
public function __construct(TraceStore $store) {
parent::__construct();
$this->store = $store;
}
protected function configure() {
$this
->setName('lockpick:clear')
->setDescription('Clear all stored conflict traces');
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$this->store->clear();
return 0;
}
}

View file

@ -101,4 +101,10 @@ class TraceStore {
return null;
}
}
public function clear(): void {
$query = $this->connection->getQueryBuilder();
$query->delete('lockpick_traces');
$query->executeStatement();
}
}